From 829491c18945897664b947fbf46ef152808e18a1 Mon Sep 17 00:00:00 2001 From: Zughy <4279489-marco_a@users.noreply.gitlab.com> Date: Sun, 20 Aug 2023 14:00:28 +0200 Subject: [PATCH] Bugfix: run on_time_tick also when timer reaches 0 (closes #242) --- DOCS.md | 2 +- src/api/in_game.lua | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/DOCS.md b/DOCS.md index 20892d4..0c241a6 100644 --- a/DOCS.md +++ b/DOCS.md @@ -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 diff --git a/src/api/in_game.lua b/src/api/in_game.lua index ed9e1ac..7244ebe 100644 --- a/src/api/in_game.lua +++ b/src/api/in_game.lua @@ -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()