For in-game information about these commands, type `/help <command name>` in the chat. For example, to learn more about the `//copy` command, simply type `/help /copy` to display information relevant to copying a region.
+Regions
+-------
+Most WorldEdit commands operate on regions. Regions are a set of two positions that define a 3D cube. They are local to each player and chat commands affect only the region for the player giving the commands.
+
+Each positions together define two opposing corners of the cube. With two opposing corners it is possible to determine both the location and dimensions of the region.
+
+Regions are not saved between server restarts. They start off as empty regions, and cannot be used with most WorldEdit commands until they are set to valid values.
+
Commands
--------
+### //reset
+
+Reset the region so that it is empty.
+
### //pos1
Set WorldEdit region position 1 to the player's location.
minetest.register_privilege("worldedit", "Can use WorldEdit commands")\r
\r
-worldedit = {}\r
+--wip: check to make sure player positions are set before doing editing\r
+--wip; fix meseconedit to export to new WorldEdit format\r
\r
-dofile(minetest.get_modpath("worldedit") .. "/functions.lua")\r
+worldedit = {}\r
\r
worldedit.set_pos = {}\r
\r
worldedit.pos1 = {}\r
worldedit.pos2 = {}\r
\r
+dofile(minetest.get_modpath("worldedit") .. "/functions.lua")\r
+dofile(minetest.get_modpath("worldedit") .. "/mark.lua")\r
+\r
--determines whether `nodename` is a valid node name, returning a boolean\r
worldedit.node_is_valid = function(temp_pos, nodename)\r
- local originalnode = minetest.env:get_node(temp_pos)\r
- minetest.env:add_node(temp_pos, {name=nodename})\r
- local value = minetest.env:get_node(temp_pos).name\r
- local equal = value == nodename or value == "default:" .. nodename\r
- minetest.env:add_node(temp_pos, originalnode)\r
- return equal\r
+ local originalnode = minetest.env:get_node(temp_pos) --save the original node to restore later\r
+ minetest.env:add_node(temp_pos, {name=nodename}) --attempt to add the node\r
+ local value = minetest.env:get_node(temp_pos).name --obtain the name of the newly added node\r
+ if value == nodename or value == "default:" .. nodename then --successfully added node\r
+ minetest.env:add_node(temp_pos, originalnode) --restore the original node\r
+ return true --node is valid\r
+ end\r
+ return false --node is not valid\r
end\r
\r
---wip: check to make sure player positions are set before doing editing\r
+minetest.register_chatcommand("/reset", {\r
+ params = "",\r
+ description = "Reset the region so that it is empty",\r
+ privs = {worldedit=true},\r
+ func = function(name, param)\r
+ worldedit.pos1[name] = nil\r
+ worldedit.pos2[name] = nil\r
+ worldedit.mark_pos1(name)\r
+ worldedit.mark_pos2(name)\r
+ minetest.chat_send_player(name, "WorldEdit region reset")\r
+ end,\r
+})\r
\r
minetest.register_chatcommand("/pos1", {\r
params = "",\r
pos.y = math.floor(pos.y)\r
pos.z = math.floor(pos.z)\r
worldedit.pos1[name] = pos\r
+ worldedit.mark_pos1(name)\r
minetest.chat_send_player(name, "WorldEdit position 1 set to (" .. pos.x .. "," .. pos.y .. "," .. pos.z .. ")")\r
end,\r
})\r
func = function(name, param)\r
local pos = minetest.env:get_player_by_name(name):getpos()\r
worldedit.pos2[name] = pos\r
+ worldedit.mark_pos2(name)\r
minetest.chat_send_player(name, "WorldEdit position 2 set to (" .. pos.x .. "," .. pos.y .. "," .. pos.z .. ")")\r
end,\r
})\r
if worldedit.set_pos[name] == 1 then --setting position 1\r
worldedit.set_pos[name] = 2 --set position 2 on the next invocation\r
worldedit.pos1[name] = pos\r
+ worldedit.mark_pos1(name)\r
minetest.chat_send_player(name, "WorldEdit region position 1 set to (" .. pos.x .. "," .. pos.y .. "," .. pos.z .. ")")\r
else --setting position 2\r
worldedit.set_pos[name] = nil --finished setting positions\r
worldedit.pos2[name] = pos\r
+ worldedit.mark_pos2(name)\r
minetest.chat_send_player(name, "WorldEdit region position 2 set to (" .. pos.x .. "," .. pos.y .. "," .. pos.z .. ")")\r
end\r
end\r
--- /dev/null
+worldedit.marker1 = {}\r
+worldedit.marker2 = {}\r
+\r
+--marks worldedit region position 1\r
+worldedit.mark_pos1 = function(name)\r
+ local pos = worldedit.pos1[name]\r
+ if worldedit.marker1[name] == nil then --marker does not yet exist\r
+ if pos ~= nil then --add marker\r
+ worldedit.marker1[name] = minetest.env:add_entity(pos, "worldedit:pos1")\r
+ end\r
+ else --marker already exists\r
+ if pos == nil then --remove marker\r
+ worldedit.marker1[name]:remove()\r
+ worldedit.marker1[name] = nil\r
+ else --move marker\r
+ worldedit.marker1[name]:setpos(pos)\r
+ end\r
+ end\r
+end\r
+\r
+--marks worldedit region position 2\r
+worldedit.mark_pos2 = function(name)\r
+ local pos = worldedit.pos2[name]\r
+ if worldedit.marker2[name] == nil then --marker does not yet exist\r
+ if pos ~= nil then --add marker\r
+ worldedit.marker2[name] = minetest.env:add_entity(pos, "worldedit:pos2")\r
+ end\r
+ else --marker already exists\r
+ if pos == nil then --remove marker\r
+ worldedit.marker2[name]:remove()\r
+ worldedit.marker2[name] = nil\r
+ else --move marker\r
+ worldedit.marker2[name]:setpos(pos)\r
+ end\r
+ end\r
+end\r
+\r
+minetest.register_entity("worldedit:pos1", {\r
+ initial_properties = {\r
+ visual = "cube",\r
+ visual_size = {x=1.1, y=1.1},\r
+ textures = {"worldedit_pos1.png", "worldedit_pos1.png",\r
+ "worldedit_pos1.png", "worldedit_pos1.png",\r
+ "worldedit_pos1.png", "worldedit_pos1.png"},\r
+ collisionbox = {-0.55, -0.55, -0.55, 0.55, 0.55, 0.55},\r
+ },\r
+ on_punch = function(self, hitter)\r
+ self.object:remove()\r
+ local name = hitter:get_player_name()\r
+ worldedit.marker1[name] = nil\r
+ end,\r
+})\r
+\r
+minetest.register_entity("worldedit:pos2", {\r
+ initial_properties = {\r
+ visual = "cube",\r
+ visual_size = {x=1.1, y=1.1},\r
+ textures = {"worldedit_pos2.png", "worldedit_pos2.png",\r
+ "worldedit_pos2.png", "worldedit_pos2.png",\r
+ "worldedit_pos2.png", "worldedit_pos2.png"},\r
+ collisionbox = {-0.55, -0.55, -0.55, 0.55, 0.55, 0.55},\r
+ },\r
+ on_punch = function(self, hitter)\r
+ self.object:remove()\r
+ local name = hitter:get_player_name()\r
+ worldedit.marker2[name] = nil\r
+ end,\r
+})
\ No newline at end of file