From 8cb684da30bcfa5b42aa2cf62602786fcd6e8603 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Mon, 17 Feb 2025 18:02:07 +0100 Subject: [PATCH] Keep area marker when running '/area_posX' twice Regression from c9f1cf2fac054 --- pos.lua | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/pos.lua b/pos.lua index aa8aba5..cc70486 100644 --- a/pos.lua +++ b/pos.lua @@ -184,14 +184,6 @@ function areas:setPos1(name, pos) pos = posLimit(pos) areas.pos1[name] = pos - local entity = minetest.add_entity(pos, "areas:pos1") - if entity then - local luaentity = entity:get_luaentity() - if luaentity then - luaentity.player = name - end - end - if old_pos then -- TODO: use `core.objects_inside_radius` after Luanti 5.10.0 is well established. for _, object in ipairs(core.get_objects_inside_radius(old_pos, 0.01)) do @@ -201,20 +193,20 @@ function areas:setPos1(name, pos) end end end -end -function areas:setPos2(name, pos) - local old_pos = areas.pos2[name] - pos = posLimit(pos) - areas.pos2[name] = pos - - local entity = minetest.add_entity(pos, "areas:pos2") + local entity = core.add_entity(pos, "areas:pos1") if entity then local luaentity = entity:get_luaentity() if luaentity then luaentity.player = name end end +end + +function areas:setPos2(name, pos) + local old_pos = areas.pos2[name] + pos = posLimit(pos) + areas.pos2[name] = pos if old_pos then -- TODO: use `core.objects_inside_radius` after Luanti 5.10.0 is well established. @@ -225,6 +217,14 @@ function areas:setPos2(name, pos) end end end + + local entity = core.add_entity(pos, "areas:pos2") + if entity then + local luaentity = entity:get_luaentity() + if luaentity then + luaentity.player = name + end + end end minetest.register_on_punchnode(function(pos, node, puncher)