summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Zhang <azhang9@gmail.com>2012-07-19 23:24:37 -0400
committerAnthony Zhang <azhang9@gmail.com>2012-07-19 23:24:37 -0400
commitc216164d742e2987da7da1b00daacdfd9fa933b3 (patch)
tree9a3b93d52f94ad2d69fd59532be139086eeb7724
parent2ecdd6cb1dd05b5627cbee32b357cfc15594809b (diff)
Simplify marker placement and fix wierd bug where object:setpos() didn't work.
-rw-r--r--mark.lua34
1 files changed, 12 insertions, 22 deletions
diff --git a/mark.lua b/mark.lua
index 228b8f0..42a0b19 100644
--- a/mark.lua
+++ b/mark.lua
@@ -4,34 +4,24 @@ worldedit.marker2 = {}
--marks worldedit region position 1
worldedit.mark_pos1 = function(name)
local pos = worldedit.pos1[name]
- if worldedit.marker1[name] == nil then --marker does not yet exist
- if pos ~= nil then --add marker
- worldedit.marker1[name] = minetest.env:add_entity(pos, "worldedit:pos1")
- end
- else --marker already exists
- if pos == nil then --remove marker
- worldedit.marker1[name]:remove()
- worldedit.marker1[name] = nil
- else --move marker
- worldedit.marker1[name]:setpos(pos)
- end
+ if worldedit.marker1[name] ~= nil then --marker already exists
+ worldedit.marker1[name]:remove() --remove marker
+ worldedit.marker1[name] = nil
+ end
+ if pos ~= nil then --add marker
+ worldedit.marker1[name] = minetest.env:add_entity(pos, "worldedit:pos1")
end
end
--marks worldedit region position 2
worldedit.mark_pos2 = function(name)
local pos = worldedit.pos2[name]
- if worldedit.marker2[name] == nil then --marker does not yet exist
- if pos ~= nil then --add marker
- worldedit.marker2[name] = minetest.env:add_entity(pos, "worldedit:pos2")
- end
- else --marker already exists
- if pos == nil then --remove marker
- worldedit.marker2[name]:remove()
- worldedit.marker2[name] = nil
- else --move marker
- worldedit.marker2[name]:setpos(pos)
- end
+ if worldedit.marker2[name] ~= nil then --marker already exists
+ worldedit.marker2[name]:remove() --remove marker
+ worldedit.marker2[name] = nil
+ end
+ if pos ~= nil then --add marker
+ worldedit.marker2[name] = minetest.env:add_entity(pos, "worldedit:pos2")
end
end