summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorzaoqi <zaomir@outlook.com>2017-03-05 01:36:37 +0800
committerLoïc Blot <nerzhul@users.noreply.github.com>2017-03-04 18:36:37 +0100
commitc9ac722ea9ab3783bf59e7cb991bfb3a91211490 (patch)
treee56a33e91e932a1f4f4eea7671447e6ee766c163 /builtin
parent6de83a2756316653ed67b23bbeb0fb43aa2a68c6 (diff)
downloadminetest-c9ac722ea9ab3783bf59e7cb991bfb3a91211490.tar.gz
minetest-c9ac722ea9ab3783bf59e7cb991bfb3a91211490.tar.bz2
minetest-c9ac722ea9ab3783bf59e7cb991bfb3a91211490.zip
Add minetest.spawn_falling_node(pos) (#5339)
* Add minetest.spawn_falling_node(pos) * lua_api.txt: Add minetest.spawn_falling_node(pos) * Update minetest.spawn_falling_node(pos)
Diffstat (limited to 'builtin')
-rw-r--r--builtin/game/falling.lua14
1 files changed, 14 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)