diff options
author | Anthony Zhang <azhang9@gmail.com> | 2012-10-21 17:49:43 -0400 |
---|---|---|
committer | Anthony Zhang <azhang9@gmail.com> | 2012-10-21 17:49:43 -0400 |
commit | aa4a70d237db22b587d46a50a21d1a71a445874e (patch) | |
tree | 042d48b7a83e28e41d25f03b481d6c08a56c373d /worldedit_commands | |
parent | 5f598db3e6ef1f30cdba9cda4b2e0f32c658de16 (diff) |
Rename //find to //highlight and worldedit.find to worldedit.highlight, add //allocate and worldedit.allocate as well as related documentation. Improve documentation by fixing a few mistakes and adding return signatures.
Diffstat (limited to 'worldedit_commands')
-rw-r--r-- | worldedit_commands/init.lua | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/worldedit_commands/init.lua b/worldedit_commands/init.lua index 1fb59d3..3931df0 100644 --- a/worldedit_commands/init.lua +++ b/worldedit_commands/init.lua @@ -567,9 +567,9 @@ minetest.register_chatcommand("/hide", { end,
})
-minetest.register_chatcommand("/find", {
+minetest.register_chatcommand("/highlight", {
params = "<node>",
- description = "Find <node> in the current WorldEdit region by hiding everything else non-destructively",
+ description = "Highlight <node> in the current WorldEdit region by hiding everything else non-destructively",
privs = {worldedit=true},
func = function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
@@ -583,8 +583,8 @@ minetest.register_chatcommand("/find", { return
end
- local count = worldedit.find(pos1, pos2, param)
- minetest.chat_send_player(name, count .. " nodes found")
+ local count = worldedit.highlight(pos1, pos2, param)
+ minetest.chat_send_player(name, count .. " nodes highlighted")
end,
})
@@ -638,6 +638,42 @@ minetest.register_chatcommand("/save", { end,
})
+minetest.register_chatcommand("/allocate", {
+ params = "<file>",
+ description = "Set the region defined by nodes from \"(world folder)/schems/<file>.we\" as the current WorldEdit region",
+ privs = {worldedit=true},
+ func = function(name, param)
+ local pos1 = worldedit.pos1[name]
+ if pos1 == nil then
+ minetest.chat_send_player(name, "No WorldEdit region selected")
+ return
+ end
+
+ if param == "" then
+ minetest.chat_send_player(name, "Invalid usage: " .. param)
+ return
+ end
+
+ local filename = minetest.get_worldpath() .. "/schems/" .. param .. ".we"
+ local file, err = io.open(filename, "rb")
+ if err ~= nil then
+ minetest.chat_send_player(name, "Could not open file \"" .. filename .. "\"")
+ return
+ end
+ local value = file:read("*a")
+ file:close()
+
+ local nodepos1, nodepos2, count = worldedit.allocate(pos1, value)
+
+ worldedit.pos1[name] = nodepos1
+ worldedit.mark_pos1(name)
+ worldedit.pos2[name] = nodepos2
+ worldedit.mark_pos2(name)
+
+ minetest.chat_send_player(name, count .. " nodes allocated")
+ end,
+})
+
minetest.register_chatcommand("/load", {
params = "<file>",
description = "Load nodes from \"(world folder)/schems/<file>.we\" with position 1 of the current WorldEdit region as the origin",
|