Skip to content

Commit be92eeb

Browse files
committed
doom lua: add and show last added thing
1 parent 6231cce commit be92eeb

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

Assets/Lua/Doom/doom.lua

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,28 @@ local function iterate()
579579
end
580580

581581
for _, mobj in pairs(Globals.mobjs:readbulk()) do
582-
local type = mobj.type
582+
local type = mobj.type
583+
local index = mobj.index
583584
local radius_color, text_color = get_mobj_color(mobj, type)
585+
586+
if #TrackedThings > 0 then
587+
local id = TrackedThings[#TrackedThings]
588+
589+
if id == index then
590+
texts.thing = string.format(
591+
"THING %d (%s)\nx: %.5f\ny: %.5f\nz: %.2f" ..
592+
" rad: %.0f\ntics: %d hp: %d\nrt: %d thre: %d",
593+
mobj.index, MobjType[type],
594+
mobj.x / FRACUNIT,
595+
mobj.y / FRACUNIT,
596+
mobj.z / FRACUNIT,
597+
mobj.radius / FRACUNIT,
598+
mobj.tics,
599+
mobj.health,
600+
mobj.reactiontime,
601+
mobj.threshold)
602+
end
603+
end
584604

585605
if radius_color or text_color then -- not hidden
586606
local pos = tuple_to_vertex(game_to_screen(mobj.x, mobj.y))
@@ -591,7 +611,6 @@ local function iterate()
591611
local type = mobj.type
592612
local radius = mobj.radius
593613
local screen_radius = math.floor((radius / FRACUNIT) * Zoom)
594-
local index = mobj.index
595614

596615
if in_range(mousePos.x, pos.x - screen_radius, pos.x + screen_radius)
597616
and in_range(mousePos.y, pos.y - screen_radius, pos.y + screen_radius)
@@ -600,7 +619,7 @@ local function iterate()
600619
radius_color = "white"
601620
text_color = "white"
602621

603-
texts.thing = string.format(
622+
texts.thing = texts.thing or string.format(
604623
"THING %d (%s)\nx: %.5f\ny: %.5f\nz: %.2f" ..
605624
" rad: %.0f\ntics: %d hp: %d\nrt: %d thre: %d",
606625
mobj.index, MobjType[type],
@@ -641,6 +660,8 @@ local function iterate()
641660
if texts.line then text(10, 320, texts.line, 0xffff8800) end
642661
if texts.sector then text(10, 370, texts.sector, 0xff00ffff) end
643662

663+
texts.thing = nil
664+
644665
-- text(50,10,shortest_dist/FRACUNIT)
645666
end
646667

@@ -798,7 +819,7 @@ local function input_prompt()
798819
elseif input.Backspace and not LastInput.Backspace and value ~= "" then
799820
value = value:sub(1, -2)
800821
elseif input.Enter and not LastInput.Enter and value ~= "" then
801-
CurrentPrompt.value = tonumber(value)
822+
CurrentPrompt.fun(tonumber(value))
802823
CurrentPrompt = nil
803824
return
804825
elseif input["Number0"] and not LastInput["Number0"] and value ~= "" then value = value .. "0"
@@ -848,10 +869,12 @@ local function add_thing()
848869
msg =
849870
"Enter thing ID from\nlevel editor.\n\n" ..
850871
"Hit \"Enter\" to send,\n\"Backspace\" to erase,\nor \"Escape\" to cancel.",
851-
fun = func,
872+
fun = function(id)
873+
table.insert(TrackedThings, id)
874+
print(TrackedThings)
875+
end,
852876
value = nil
853877
}
854-
-- table.insert(TrackedThings
855878
end
856879

857880
local function add_line()

0 commit comments

Comments
 (0)