From bb8456b71119ca6303b9e9706829a84dc7f81ab3 Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Wed, 29 Oct 2014 22:47:08 -0400 Subject: Cleanup and fixup Non-stylistic changes: * Add LuaDoc/LDoc support. * Fix `clear_objects` area size calculation. * Fix `clear_objects` removing player objects. * Fix shadowing of marker entity name with player name. * Make visualization functions use `swap_node`. * Make hidden nodes unwalkable. * Prevent `hide` from hiding air. * Make deprecated functions log to deprecated stream when called. * Fixed `replaceinverse` not using normalized node names. * Added .gitignore. * Bump version to 1.1. Stylistic changes: * Change `x = function` to `function x`. * Change comment format. * Make missing VoxelManip error less obnoxious. * Move `sort_pos` into `common.lua`, which is a required module. * Remove local copies of `minetest`. * Remove `worldedit = worldedit or {}` from modules. * Replace replaceinverse with an inverse argument to `replace`. * Added `error()`s on on invalid axes. * Change `wip` to `TODO`. * Rename `clearobjects` to `clear_objects`. * Remove `hollow_{sphere,dome,cylinder}` and replace them with a hollow parameter to each function. * Add helpers to reduce code duplication. * Renamed `Chat Commands.md` to `ChatCommands.md`. --- worldedit_commands/init.lua | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'worldedit_commands/init.lua') diff --git a/worldedit_commands/init.lua b/worldedit_commands/init.lua index 9daa809..424082f 100644 --- a/worldedit_commands/init.lua +++ b/worldedit_commands/init.lua @@ -1,7 +1,5 @@ minetest.register_privilege("worldedit", "Can use WorldEdit commands") ---wip: fold the hollow stuff into the main functions and add a hollow flag at the end, then add the compatibility stuff - worldedit.set_pos = {} worldedit.inspect = {} @@ -340,10 +338,11 @@ minetest.register_chatcommand("/replace", { description = "Replace all instances of with in the current WorldEdit region", privs = {worldedit=true}, func = safe_region(function(name, param) - local found, _, searchnode, replacenode = param:find("^([^%s]+)%s+(.+)$") - local newsearchnode = worldedit.normalize_nodename(searchnode) - local newreplacenode = worldedit.normalize_nodename(replacenode) - local count = worldedit.replace(worldedit.pos1[name], worldedit.pos2[name], newsearchnode, newreplacenode) + local found, _, search_node, replace_node = param:find("^([^%s]+)%s+(.+)$") + local norm_search_node = worldedit.normalize_nodename(search_node) + local norm_replace_node = worldedit.normalize_nodename(replace_node) + local count = worldedit.replace(worldedit.pos1[name], worldedit.pos2[name], + norm_search_node, norm_replace_node) worldedit.player_notify(name, count .. " nodes replaced") end, check_replace), }) @@ -353,10 +352,11 @@ minetest.register_chatcommand("/replaceinverse", { description = "Replace all nodes other than with in the current WorldEdit region", privs = {worldedit=true}, func = safe_region(function(name, param) - local found, _, searchnode, replacenode = param:find("^([^%s]+)%s+(.+)$") - local newsearchnode = worldedit.normalize_nodename(searchnode) - local newreplacenode = worldedit.normalize_nodename(replacenode) - local count = worldedit.replaceinverse(worldedit.pos1[name], worldedit.pos2[name], searchnode, replacenode) + local found, _, search_node, replace_node = param:find("^([^%s]+)%s+(.+)$") + local norm_search_node = worldedit.normalize_nodename(search_node) + local norm_replace_node = worldedit.normalize_nodename(replace_node) + local count = worldedit.replace(worldedit.pos1[name], worldedit.pos2[name], + norm_search_node, norm_replace_node, true) worldedit.player_notify(name, count .. " nodes replaced") end, check_replace), }) @@ -383,7 +383,7 @@ minetest.register_chatcommand("/hollowsphere", { func = safe_region(function(name, param) local found, _, radius, nodename = param:find("^(%d+)%s+(.+)$") local node = get_node(name, nodename) - local count = worldedit.hollow_sphere(worldedit.pos1[name], tonumber(radius), node) + local count = worldedit.sphere(worldedit.pos1[name], tonumber(radius), node, true) worldedit.player_notify(name, count .. " nodes added") end, check_sphere), }) @@ -422,7 +422,7 @@ minetest.register_chatcommand("/hollowdome", { func = safe_region(function(name, param) local found, _, radius, nodename = param:find("^(%d+)%s+(.+)$") local node = get_node(name, nodename) - local count = worldedit.hollow_dome(worldedit.pos1[name], tonumber(radius), node) + local count = worldedit.dome(worldedit.pos1[name], tonumber(radius), node, true) worldedit.player_notify(name, count .. " nodes added") end, check_dome), }) @@ -466,7 +466,7 @@ minetest.register_chatcommand("/hollowcylinder", { length = length * sign end local node = get_node(name, nodename) - local count = worldedit.hollow_cylinder(worldedit.pos1[name], axis, length, tonumber(radius), node) + local count = worldedit.cylinder(worldedit.pos1[name], axis, length, tonumber(radius), node, true) worldedit.player_notify(name, count .. " nodes added") end, check_cylinder), }) @@ -1114,7 +1114,7 @@ minetest.register_chatcommand("/clearobjects", { description = "Clears all objects within the WorldEdit region", privs = {worldedit=true}, func = safe_region(function(name, param) - local count = worldedit.clearobjects(worldedit.pos1[name], worldedit.pos2[name]) + local count = worldedit.clear_objects(worldedit.pos1[name], worldedit.pos2[name]) worldedit.player_notify(name, count .. " objects cleared") end), }) -- cgit v1.2.3