mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-26 12:31:05 +01:00
Finish at max_stage not max_stage + 1
This commit is contained in:
parent
f06d5a1ee3
commit
627ce0dc3b
1 changed files with 8 additions and 5 deletions
|
@ -44,10 +44,12 @@ local etime = 0
|
||||||
function check_events(dtime)
|
function check_events(dtime)
|
||||||
for idx,ae in pairs(active_events) do
|
for idx,ae in pairs(active_events) do
|
||||||
if ae.cond_complete and ae:cond_complete() then
|
if ae.cond_complete and ae:cond_complete() then
|
||||||
|
ae.finished = true
|
||||||
finish_event(ae,idx)
|
finish_event(ae,idx)
|
||||||
elseif ae.max_stage and ae.max_stage < ae.stage then
|
elseif not ae.cond_complete and ae.max_stage and ae.max_stage <= ae.stage then
|
||||||
|
ae.finished = true
|
||||||
finish_event(ae,idx)
|
finish_event(ae,idx)
|
||||||
elseif ae.cond_progress then
|
elseif not ae.finished and ae.cond_progress then
|
||||||
local p = ae:cond_progress()
|
local p = ae:cond_progress()
|
||||||
if p == true then
|
if p == true then
|
||||||
ae.stage = ae.stage + 1
|
ae.stage = ae.stage + 1
|
||||||
|
@ -58,8 +60,7 @@ function check_events(dtime)
|
||||||
minetest.log("event progressed to stage "..ae.stage)
|
minetest.log("event progressed to stage "..ae.stage)
|
||||||
ae:on_stage_begin()
|
ae:on_stage_begin()
|
||||||
end
|
end
|
||||||
|
elseif not ae.finished and ae.on_step then
|
||||||
elseif ae.on_step then
|
|
||||||
ae:on_step()
|
ae:on_step()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -92,7 +93,6 @@ mcl_events.register_event("infestation",{
|
||||||
end,
|
end,
|
||||||
on_start = function(self)
|
on_start = function(self)
|
||||||
self.mobs = {}
|
self.mobs = {}
|
||||||
minetest.log("inf")
|
|
||||||
end,
|
end,
|
||||||
cond_progress = function(self)
|
cond_progress = function(self)
|
||||||
local m = {}
|
local m = {}
|
||||||
|
@ -113,6 +113,9 @@ mcl_events.register_event("infestation",{
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
cond_complete = function(self)
|
||||||
|
return self.stage >= self.max_stage
|
||||||
|
end,
|
||||||
on_complete = function(self)
|
on_complete = function(self)
|
||||||
minetest.log("INFESTATION complete")
|
minetest.log("INFESTATION complete")
|
||||||
end,
|
end,
|
||||||
|
|
Loading…
Reference in a new issue