Skip to content

Commit 04884d0

Browse files
committed
Give modes more control over the build timer
1 parent 69d1ff1 commit 04884d0

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

mods/ctf/ctf_modebase/build_timer.lua

+7-5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ local function timer_func(time_left)
4747
timer = minetest.after(1, timer_func, time_left - 1)
4848
end
4949

50+
function ctf_modebase.build_timer.start(build_time)
51+
local time = build_time or ctf_modebase:get_current_mode().build_timer or DEFAULT_BUILD_TIME
52+
53+
if time > 0 then
54+
timer = timer_func(time)
55+
end
56+
end
5057

5158
function ctf_modebase.build_timer.finish()
5259
if timer == nil then return end
@@ -76,10 +83,6 @@ function ctf_modebase.build_timer.finish()
7683
end
7784
end
7885

79-
ctf_api.register_on_new_match(function()
80-
timer = minetest.after(1, timer_func, ctf_modebase:get_current_mode().build_timer or DEFAULT_BUILD_TIME)
81-
end)
82-
8386
ctf_api.register_on_match_end(function()
8487
if timer == nil then return end
8588
timer:cancel()
@@ -119,4 +122,3 @@ minetest.register_chatcommand("ctf_start", {
119122
return true, "Build time ended"
120123
end,
121124
})
122-

mods/ctf/ctf_modebase/features.lua

+2
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,8 @@ return {
464464
minetest.after(math.max(0, LOADING_SCREEN_TARGET_TIME - total_time), function()
465465
hud:clear_all()
466466
set_playertags_state(PLAYERTAGS_ON)
467+
468+
ctf_modebase.build_timer.start()
467469
end)
468470
end
469471
end,

0 commit comments

Comments
 (0)