parent
63d2ccf0fa
commit
afb113dc5a
|
@ -26,17 +26,12 @@ local function check()
|
|||
local area_list = areas:getAreasAtPos(ppos)
|
||||
local current_ids = {}
|
||||
|
||||
-- check areas
|
||||
for id in pairs(area_list) do
|
||||
-- mark current ids
|
||||
for id in pairs(area_list) do
|
||||
current_ids[id] = true
|
||||
if not active_entry[id] then
|
||||
-- player entered
|
||||
area_effects.run_hook("enter", { player, id })
|
||||
active_entry[id] = true
|
||||
end
|
||||
end
|
||||
|
||||
-- check previous area-ids
|
||||
-- check previous area-ids
|
||||
for id in pairs(active_entry) do
|
||||
if not current_ids[id] then
|
||||
-- player left
|
||||
|
@ -44,6 +39,15 @@ local function check()
|
|||
active_entry[id] = nil
|
||||
end
|
||||
end
|
||||
|
||||
-- check new areas
|
||||
for id in pairs(area_list) do
|
||||
if not active_entry[id] then
|
||||
-- player entered
|
||||
area_effects.run_hook("enter", { player, id })
|
||||
active_entry[id] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.after(1, check)
|
||||
|
|
Loading…
Reference in New Issue