summaryrefslogtreecommitdiff
path: root/mark.lua
diff options
context:
space:
mode:
authorAnthony Zhang <azhang9@gmail.com>2012-07-16 14:38:15 -0400
committerAnthony Zhang <azhang9@gmail.com>2012-07-16 14:38:15 -0400
commitb6933816b8740031a64f32862d8987a345e1abc3 (patch)
tree7e10db426ef77c43ec007358b83e3bb5ef232f5f /mark.lua
parent6a6f37460de55ad23cd1f4121a7a3d3b0e91901d (diff)
Add entities to mark the WorldEdit region positions and add the //reset command. Document regions, and the //reset command.
Diffstat (limited to 'mark.lua')
-rw-r--r--mark.lua68
1 files changed, 68 insertions, 0 deletions
diff --git a/mark.lua b/mark.lua
new file mode 100644
index 0000000..228b8f0
--- /dev/null
+++ b/mark.lua
@@ -0,0 +1,68 @@
+worldedit.marker1 = {}
+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
+ 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
+ end
+end
+
+minetest.register_entity("worldedit:pos1", {
+ initial_properties = {
+ visual = "cube",
+ visual_size = {x=1.1, y=1.1},
+ textures = {"worldedit_pos1.png", "worldedit_pos1.png",
+ "worldedit_pos1.png", "worldedit_pos1.png",
+ "worldedit_pos1.png", "worldedit_pos1.png"},
+ collisionbox = {-0.55, -0.55, -0.55, 0.55, 0.55, 0.55},
+ },
+ on_punch = function(self, hitter)
+ self.object:remove()
+ local name = hitter:get_player_name()
+ worldedit.marker1[name] = nil
+ end,
+})
+
+minetest.register_entity("worldedit:pos2", {
+ initial_properties = {
+ visual = "cube",
+ visual_size = {x=1.1, y=1.1},
+ textures = {"worldedit_pos2.png", "worldedit_pos2.png",
+ "worldedit_pos2.png", "worldedit_pos2.png",
+ "worldedit_pos2.png", "worldedit_pos2.png"},
+ collisionbox = {-0.55, -0.55, -0.55, 0.55, 0.55, 0.55},
+ },
+ on_punch = function(self, hitter)
+ self.object:remove()
+ local name = hitter:get_player_name()
+ worldedit.marker2[name] = nil
+ end,
+}) \ No newline at end of file