summaryrefslogtreecommitdiff
path: root/worldedit_commands/mark.lua
diff options
context:
space:
mode:
authorAnthony Zhang <azhang9@gmail.com>2012-10-13 21:45:50 -0400
committerAnthony Zhang <azhang9@gmail.com>2012-10-13 21:45:50 -0400
commit1c31bd7f0d78447ea35e195b59fc1b2577ebaf18 (patch)
tree812a403a693caf557da16404d560afa8d3cd366b /worldedit_commands/mark.lua
parent12dfbd198d117b9d76e86a056f79b7276e8db0a6 (diff)
Separate components into separate mods, add visualization API with hide(), suppress(), find(), and restore() for nondestructive node visualization. Corresponding chat commands are //hide, //suppress, //find, and //restore. Commands and functions documented.
Diffstat (limited to 'worldedit_commands/mark.lua')
-rw-r--r--worldedit_commands/mark.lua70
1 files changed, 70 insertions, 0 deletions
diff --git a/worldedit_commands/mark.lua b/worldedit_commands/mark.lua
new file mode 100644
index 0000000..d2568ed
--- /dev/null
+++ b/worldedit_commands/mark.lua
@@ -0,0 +1,70 @@
+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 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")
+ worldedit.marker1[name]:get_luaentity().active = true
+ end
+end
+
+--marks worldedit region position 2
+worldedit.mark_pos2 = function(name)
+ local pos = worldedit.pos2[name]
+ 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")
+ worldedit.marker2[name]:get_luaentity().active = true
+ 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_step = function(self, dtime)
+ if self.active == nil then
+ self.object:remove()
+ end
+ end,
+ 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_step = function(self, dtime)
+ if self.active == nil then
+ self.object:remove()
+ end
+ end,
+ 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