Fix minor bug in mcl_time

This commit is contained in:
kay27 2022-02-20 04:35:46 +04:00
parent a634137436
commit 5ec7c5d246
2 changed files with 5 additions and 5 deletions

View File

@ -1,4 +1,4 @@
# mcl_time v2.1
# mcl_time v2.2
## by kay27 for MineClone 5
---------------------------
This mod counts time when all players sleep or some area is inactive.

View File

@ -102,7 +102,7 @@ function mcl_time.get_number_of_times_at_pos(pos, interval, chance)
local meta = minetest.get_meta(pos)
local last_time = meta:get_int(meta_name)
meta:set_int(meta_name, seconds_irl_public)
local number_of_times = (last_time == 0) and 0 or get_number_of_times(last_time, interval, chance)
local number_of_times = (last_time <= 0) and 0 or get_number_of_times(last_time, interval, chance)
return number_of_times
end
@ -125,7 +125,7 @@ function mcl_time.get_irl_seconds_passed_at_pos(pos)
local meta = minetest.get_meta(pos)
local last_time = meta:get_int(meta_name)
meta:set_int(meta_name, seconds_irl_public)
local irl_seconds_passed = (last_time == 0) and 0 or (seconds_irl_public - last_time)
local irl_seconds_passed = (last_time <= 0) and 0 or (seconds_irl_public - last_time)
return irl_seconds_passed
end
@ -135,7 +135,7 @@ function mcl_time.get_irl_seconds_passed_at_pos_or_1(pos)
local meta = minetest.get_meta(pos)
local last_time = meta:get_int(meta_name)
meta:set_int(meta_name, seconds_irl_public)
local irl_seconds_passed = (last_time == 0) and 1 or (seconds_irl_public - last_time)
local irl_seconds_passed = (last_time <= 0) and 1 or (seconds_irl_public - last_time)
return irl_seconds_passed
end
@ -145,7 +145,7 @@ function mcl_time.get_irl_seconds_passed_at_pos_or_nil(pos)
local meta = minetest.get_meta(pos)
local last_time = meta:get_int(meta_name)
meta:set_int(meta_name, seconds_irl_public)
if last_time == 0 then return end
if last_time <= 0 then return end
local delta_time = seconds_irl_public - last_time
if delta_time <= 0 then return end
return delta_time