aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/game/falling.lua14
-rw-r--r--doc/lua_api.txt3
2 files changed, 17 insertions, 0 deletions
diff --git a/builtin/game/falling.lua b/builtin/game/falling.lua
index 5ef5289be..764909361 100644
--- a/builtin/game/falling.lua
+++ b/builtin/game/falling.lua
@@ -118,6 +118,20 @@ local function spawn_falling_node(p, node)
end
end
+function core.spawn_falling_node(pos)
+ local node = core.get_node(pos)
+ if node.name == "air" or node.name == "ignore" then
+ return false
+ end
+ local obj = core.add_entity(pos, "__builtin:falling_node")
+ if obj then
+ obj:get_luaentity():set_node(node)
+ core.remove_node(pos)
+ return true
+ end
+ return false
+end
+
local function drop_attached_node(p)
local nn = core.get_node(p).name
core.remove_node(p)
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index 7b956dc74..23aac90d9 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -2219,6 +2219,9 @@ and `minetest.auth_reload` call the authetification handler.
* Returns `true` if successful, `false` on failure (e.g. protected location)
* `minetest.punch_node(pos)`
* Punch node with the same effects that a player would cause
+* `minetest.spawn_falling_node(pos)`
+ * Change node into falling node
+ * Returns `true` if successful, `false` on failure
* `minetest.find_nodes_with_meta(pos1, pos2)`
* Get a table of positions of nodes that have metadata within a region {pos1, pos2}