diff options
author | ShadowNinja <shadowninja@minetest.net> | 2014-10-29 22:47:08 -0400 |
---|---|---|
committer | ShadowNinja <shadowninja@minetest.net> | 2015-02-01 15:56:16 -0500 |
commit | bb8456b71119ca6303b9e9706829a84dc7f81ab3 (patch) | |
tree | 919026712fb25b847ef8d09626400bbf0fd556eb /worldedit_commands/init.lua | |
parent | 1f277147ca03788b784ee13fb1dd4e07889b4b59 (diff) |
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`.
Diffstat (limited to 'worldedit_commands/init.lua')
-rw-r--r-- | worldedit_commands/init.lua | 28 |
1 files changed, 14 insertions, 14 deletions
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 <search node> with <replace node> 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 <search node> with <replace node> 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),
})
|