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