Bugfix: run on_time_tick also when timer reaches 0 (closes #242)

This commit is contained in:
Zughy 2023-08-20 14:00:28 +02:00
parent 9daaee8307
commit 829491c189
2 changed files with 5 additions and 3 deletions

View File

@ -109,7 +109,7 @@ The second field, on the contrary, is a table of optional parameters: they defin
* `time_mode`: (string) whether arenas will keep track of the time or not
* `"none"`: no time tracking at all (default)
* `"incremental"`: incremental time (0, 1, 2, ...)
* `"decremental"`: decremental time, as in a timer (3, 2, 1, 0). The timer value is 300 seconds by default, but it can be changed per arena
* `"decremental"`: decremental time, as in a timer (3, 2, 1, 0). The timer value is 300 seconds by default, but it can be changed per arena. Time stops ticking when it reaches 0
* `load_time`: (int) the time in seconds between the loading state and the start of the match. Default is `5`
* `celebration_time`: (int) the time in seconds between the celebration state and the end of the match. Must be greater than 0. Default is `5`
* `in_game_physics`: (table) a physical override to set to each player when they enter an arena, following the Minetest `physics_override` parameters

View File

@ -1290,11 +1290,13 @@ function time_loop(mod_ref, arena)
arena.current_time = arena.current_time - 1
end
if mod_ref.on_time_tick then
mod_ref.on_time_tick(arena)
end
if arena.current_time <= 0 then
mod_ref.on_timeout(arena)
return
elseif mod_ref.on_time_tick then
mod_ref.on_time_tick(arena)
end
minetest.after(1, function()