So I added a nice GUI to show some stuff https://ibb.co/5hSN5H8F
Code:
"
-- Create the countdown label for a player (e.g., when they join or mod initializes)
function create_tde_info_gui(player)
if player.gui.left.tde_info_frame then
player.gui.left.tde_info_frame.destroy()
end
local frame = player.gui.left.add{
type = "frame",
name = "tde_info_frame",
caption = "⚔ TDE Status",
direction = "vertical"
}
frame.style.font = "default-bold"
frame.style.minimal_width = 200
frame.add{type = "label", name = "wave_timer_label", caption = "Next wave in: 60s"}
frame.add{type = "label", name = "current_wave_label", caption = "Current wave: 1"}
frame.add{type = "label", name = "next_boss_label", caption = string.format("Next boss in: %d waves", 10)}
frame.add{type = "label", name = "kill_count_label", caption = "Kills: 0"}
frame.add{type = "label", name = "research_count_label", caption = "Research: 0"}
-- Check if it already exists, remove if so (optional)
if player.gui.top.tde_wave_timer then
player.gui.top.tde_wave_timer.destroy()
end
end
function update_tde_info_gui(player) -- Updating GUI
local frame = player.gui.left.tde_info_frame
if not frame then return end
-- Wave countdown logic (your original)
local _, next_wave_tick = tde_calculate_wave_state()
local remaining = next_wave_tick - game.tick
local minutes = math.floor(remaining / 3600)
local seconds = math.floor((remaining % 3600) / 60)
local countdown = (remaining > 0)
and string.format("Next wave in: %02d:%02d", minutes, seconds)
or "⚠️ Wave arriving!"
local waves_since_last_boss = global.tde.wave_count % BOSS_EVERY
local waves_until_next_boss = BOSS_EVERY - waves_since_last_boss
if waves_until_next_boss == BOSS_EVERY then
waves_until_next_boss = 0 -- We're on a boss wave
frame.next_boss_label.caption = string.format("Next boss in: ⚠️ BOSS WAVE ⚠️")
else
frame.next_boss_label.caption = string.format("Next boss in: %d waves", waves_until_next_boss)
end
-- Update GUI labels
frame.wave_timer_label.caption = countdown
frame.current_wave_label.caption = "Current wave: " .. tostring(global.tde.wave_count or 0)
frame.kill_count_label.caption = "Kills: " .. tostring(global.tde.total_kills or 0)
frame.research_count_label.caption = "Research: " .. tostring(global.tde.research_count or 0)
end
"
Then added to init, player join, create and the update in the nth tick - nth I did a % 60 to ensure it updates once per second - I know it should only run once per 60 tick, but I like doing that :p
"
if event.tick % 60 == 0 then
for _, player in pairs(game.connected_players) do
update_tde_info_gui(player)
end
end
"
here's the example on player created
"
if player then
create_tde_info_gui(player)
end
"
I got the tech work, and some stuff in the bug post I made