summaryrefslogtreecommitdiff
path: root/worldedit/compatibility.lua
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2014-10-29 22:47:08 -0400
committerShadowNinja <shadowninja@minetest.net>2015-02-01 15:56:16 -0500
commitbb8456b71119ca6303b9e9706829a84dc7f81ab3 (patch)
tree919026712fb25b847ef8d09626400bbf0fd556eb /worldedit/compatibility.lua
parent1f277147ca03788b784ee13fb1dd4e07889b4b59 (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/compatibility.lua')
-rw-r--r--worldedit/compatibility.lua50
1 files changed, 44 insertions, 6 deletions
diff --git a/worldedit/compatibility.lua b/worldedit/compatibility.lua
index e44e43b..c989a05 100644
--- a/worldedit/compatibility.lua
+++ b/worldedit/compatibility.lua
@@ -1,11 +1,21 @@
-worldedit = worldedit or {}
-local minetest = minetest --local copy of global
+--- Compatibility functions.
+-- @module worldedit.compatibility
+
+local function deprecated(new_func)
+ local info = debug.getinfo(1, "n")
+ local msg = "worldedit." .. info.name .. "() is deprecated."
+ if new_func then
+ msg = msg .. " Use worldedit." .. new_func .. "() instead."
+ end
+ minetest.log("deprecated", msg)
+end
worldedit.allocate_old = worldedit.allocate
worldedit.deserialize_old = worldedit.deserialize
-worldedit.metasave = function(pos1, pos2, filename)
+function worldedit.metasave(pos1, pos2, filename)
+ deprecated("save")
local file, err = io.open(filename, "wb")
if err then return 0 end
local data, count = worldedit.serialize(pos1, pos2)
@@ -14,7 +24,8 @@ worldedit.metasave = function(pos1, pos2, filename)
return count
end
-worldedit.metaload = function(originpos, filename)
+function worldedit.metaload(originpos, filename)
+ deprecated("load")
filename = minetest.get_worldpath() .. "/schems/" .. file .. ".wem"
local file, err = io.open(filename, "wb")
if err then return 0 end
@@ -22,11 +33,13 @@ worldedit.metaload = function(originpos, filename)
return worldedit.deserialize(originpos, data)
end
-worldedit.scale = function(pos1, pos2, factor)
+function worldedit.scale(pos1, pos2, factor)
+ deprecated("stretch")
return worldedit.stretch(pos1, pos2, factor, factor, factor)
end
-worldedit.valueversion = function(value)
+function worldedit.valueversion(value)
+ deprecated("read_header")
local version = worldedit.read_header(value)
if not version or version > worldedit.LATEST_SERIALIZATION_VERSION then
return 0
@@ -34,3 +47,28 @@ worldedit.valueversion = function(value)
return version
end
+function worldedit.replaceinverse(pos1, pos2, search_node, replace_node)
+ deprecated("replace")
+ return worldedit.replace(pos1, pos2, search_node, replace_node, true)
+end
+
+function worldedit.clearobjects(...)
+ deprecated("clear_objects")
+ return worldedit.clear_objects(...)
+end
+
+function worldedit.hollow_sphere(pos, radius, node_name)
+ deprecated("sphere")
+ return worldedit.sphere(pos, radius, node_name, true)
+end
+
+function worldedit.hollow_dome(pos, radius, node_name)
+ deprecated("dome")
+ return worldedit.dome(pos, radius, node_name, true)
+end
+
+function worldedit.hollow_cylinder(pos, axis, length, radius, node_name)
+ deprecated("cylinder")
+ return worldedit.cylinder(pos, axis, length, radius, node_name, true)
+end
+