From e2f1c4ef174443b2807aa94a209261546bbf19fb Mon Sep 17 00:00:00 2001 From: Anthony Zhang Date: Sat, 12 Jan 2013 18:20:41 -0500 Subject: Add //homogenize, //lua, and //luatransform commands, as well as their documentation. --- worldedit_commands/init.lua | 59 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) (limited to 'worldedit_commands/init.lua') diff --git a/worldedit_commands/init.lua b/worldedit_commands/init.lua index 15220c6..a2e6246 100644 --- a/worldedit_commands/init.lua +++ b/worldedit_commands/init.lua @@ -169,7 +169,7 @@ minetest.register_chatcommand("/set", { minetest.register_chatcommand("/replace", { params = " ", - description = "Replace all instances of with in the current WorldEdit region", + description = "Replace all instances of with in the current WorldEdit region", privs = {worldedit=true}, func = function(name, param) local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] @@ -197,6 +197,27 @@ minetest.register_chatcommand("/replace", { end, }) +minetest.register_chatcommand("/homogenize", { + params = "", + description = "Replace all non-air nodes with in the current WorldEdit region", + privs = {worldedit=true}, + func = function(name, param) + local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] + if pos1 == nil or pos2 == nil then + minetest.chat_send_player(name, "No WorldEdit region selected") + return + end + + if not worldedit.node_is_valid(param) then + minetest.chat_send_player(name, "Invalid node name: " .. param) + return + end + + local count = worldedit.homogenize(pos1, pos2, param) + minetest.chat_send_player(name, count .. " nodes homogenized") + end, +}) + minetest.register_chatcommand("/hollowsphere", { params = " ", description = "Add hollow sphere at WorldEdit position 1 with radius , composed of ", @@ -811,9 +832,43 @@ minetest.register_chatcommand("/metaload", { end local count, err = worldedit.metaload(pos1, param) if err then - minetest.chat_send_player(name, "error loading file: " .. err) + minetest.chat_send_player(name, "Error loading file: " .. err) else minetest.chat_send_player(name, count .. " nodes loaded") end end, }) + +minetest.register_chatcommand("/lua", { + params = "", + description = "Executes as a Lua chunk in the global namespace", + privs = {worldedit=true}, + func = function(name, param) + local err = worldedit.lua(param) + if err then + minetest.chat_send_player(name, "Code error: " .. err) + else + minetest.chat_send_player(name, "Code successfully executed") + end + end, +}) + +minetest.register_chatcommand("/luatransform", { + params = "", + description = "Executes as a Lua chunk in the global namespace with the variable pos available, for each node in the current WorldEdit region", + privs = {worldedit=true}, + func = function(name, param) + local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] + if pos1 == nil or pos2 == nil then + minetest.chat_send_player(name, "No WorldEdit region selected") + return + end + + local err = worldedit.luatransform(pos1, pos2, param) + if err then + minetest.chat_send_player(name, "Code error: " .. err) + else + minetest.chat_send_player(name, "Code successfully executed") + end + end, +}) \ No newline at end of file -- cgit v1.2.3