aboutsummaryrefslogtreecommitdiff
path: root/builtin/game
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2016-11-12 10:55:26 +0100
committerest31 <MTest31@outlook.com>2016-11-14 13:08:22 +0100
commit649448a2a91fbf3e944b2f2e739f4e2292af1df0 (patch)
tree5008360c4d239d5dfff8eee78b5ea79f69e176dc /builtin/game
parent6707d622bbb298e4884eedc7791c81af1da43e92 (diff)
downloadminetest-649448a2a91fbf3e944b2f2e739f4e2292af1df0.tar.gz
minetest-649448a2a91fbf3e944b2f2e739f4e2292af1df0.tar.bz2
minetest-649448a2a91fbf3e944b2f2e739f4e2292af1df0.zip
Rename nodeupdate and nodeupdate_single and make them part of the official API
Now, the renamed forms of nodeupdate and nodeupdate_single are part of the official API. As nodeupdate has been used by Minetest Game and in mods despite of not being part of the official API, we ease the transition by still supporting it for the 0.4.15 release. After the release, the two functions can be removed. The removal will not violate the stability promise, as that promise only includes the official and documented API. Also, make some formerly global functions local. They most likely haven't been used by mods, therefore they won't get stubs with deprecation warnings, hard erroring directly.
Diffstat (limited to 'builtin/game')
-rw-r--r--builtin/game/falling.lua46
1 files changed, 31 insertions, 15 deletions
diff --git a/builtin/game/falling.lua b/builtin/game/falling.lua
index 1932b170a..ece08b325 100644
--- a/builtin/game/falling.lua
+++ b/builtin/game/falling.lua
@@ -98,7 +98,7 @@ core.register_entity(":__builtin:falling_node", {
core.add_node(np, self.node)
end
self.object:remove()
- nodeupdate(np)
+ core.check_for_falling(np)
return
end
local vel = self.object:getvelocity()
@@ -109,12 +109,12 @@ core.register_entity(":__builtin:falling_node", {
end
})
-function spawn_falling_node(p, node)
+local function spawn_falling_node(p, node)
local obj = core.add_entity(p, "__builtin:falling_node")
obj:get_luaentity():set_node(node)
end
-function drop_attached_node(p)
+local function drop_attached_node(p)
local nn = core.get_node(p).name
core.remove_node(p)
for _, item in pairs(core.get_node_drops(nn, "")) do
@@ -127,7 +127,7 @@ function drop_attached_node(p)
end
end
-function check_attached_node(p, n)
+local function check_attached_node(p, n)
local def = core.registered_nodes[n.name]
local d = {x = 0, y = 0, z = 0}
if def.paramtype2 == "wallmounted" then
@@ -152,7 +152,7 @@ end
-- Some common functions
--
-function nodeupdate_single(p)
+function core.check_single_for_falling(p)
local n = core.get_node(p)
if core.get_item_group(n.name, "falling_node") ~= 0 then
local p_bottom = {x = p.x, y = p.y - 1, z = p.z}
@@ -190,7 +190,7 @@ end
-- We don't walk diagonals, only our direct neighbors, and self.
-- Down first as likely case, but always before self. The same with sides.
-- Up must come last, so that things above self will also fall all at once.
-local nodeupdate_neighbors = {
+local check_for_falling_neighbors = {
{x = -1, y = -1, z = 0},
{x = 1, y = -1, z = 0},
{x = 0, y = -1, z = -1},
@@ -204,7 +204,7 @@ local nodeupdate_neighbors = {
{x = 0, y = 1, z = 0},
}
-function nodeupdate(p)
+function core.check_for_falling(p)
-- Round p to prevent falling entities to get stuck.
p = vector.round(p)
@@ -223,10 +223,10 @@ function nodeupdate(p)
n = n + 1
s[n] = {p = p, v = v}
-- Select next node from neighbor list.
- p = vector.add(p, nodeupdate_neighbors[v])
+ p = vector.add(p, check_for_falling_neighbors[v])
-- Now we check out the node. If it is in need of an update,
-- it will let us know in the return value (true = updated).
- if not nodeupdate_single(p) then
+ if not core.check_single_for_falling(p) then
-- If we don't need to "recurse" (walk) to it then pop
-- our previous pos off the stack and continue from there,
-- with the v value we were at when we last were at that
@@ -258,17 +258,33 @@ end
-- Global callbacks
--
-function on_placenode(p, node)
- nodeupdate(p)
+local function on_placenode(p, node)
+ core.check_for_falling(p)
end
core.register_on_placenode(on_placenode)
-function on_dignode(p, node)
- nodeupdate(p)
+local function on_dignode(p, node)
+ core.check_for_falling(p)
end
core.register_on_dignode(on_dignode)
-function on_punchnode(p, node)
- nodeupdate(p)
+local function on_punchnode(p, node)
+ core.check_for_falling(p)
end
core.register_on_punchnode(on_punchnode)
+
+--
+-- Globally exported functions
+--
+
+-- TODO remove this function after the 0.4.15 release
+function nodeupdate(p)
+ core.log("deprecated", "nodeupdate: deprecated, please use core.check_for_falling instead")
+ core.check_for_falling(p)
+end
+
+-- TODO remove this function after the 0.4.15 release
+function nodeupdate_single(p)
+ core.log("deprecated", "nodeupdate_single: deprecated, please use core.check_single_for_falling instead")
+ core.check_single_for_falling(p)
+end