Skip to content

Commit c9ac722

Browse files
zaoqinerzhul
authored andcommittedMar 4, 2017
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)
1 parent 6de83a2 commit c9ac722

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed
 

‎builtin/game/falling.lua

+14
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,20 @@ local function spawn_falling_node(p, node)
118118
end
119119
end
120120

121+
function core.spawn_falling_node(pos)
122+
local node = core.get_node(pos)
123+
if node.name == "air" or node.name == "ignore" then
124+
return false
125+
end
126+
local obj = core.add_entity(pos, "__builtin:falling_node")
127+
if obj then
128+
obj:get_luaentity():set_node(node)
129+
core.remove_node(pos)
130+
return true
131+
end
132+
return false
133+
end
134+
121135
local function drop_attached_node(p)
122136
local nn = core.get_node(p).name
123137
core.remove_node(p)

‎doc/lua_api.txt

+3
Original file line numberDiff line numberDiff line change
@@ -2219,6 +2219,9 @@ and `minetest.auth_reload` call the authetification handler.
22192219
* Returns `true` if successful, `false` on failure (e.g. protected location)
22202220
* `minetest.punch_node(pos)`
22212221
* Punch node with the same effects that a player would cause
2222+
* `minetest.spawn_falling_node(pos)`
2223+
* Change node into falling node
2224+
* Returns `true` if successful, `false` on failure
22222225

22232226
* `minetest.find_nodes_with_meta(pos1, pos2)`
22242227
* Get a table of positions of nodes that have metadata within a region {pos1, pos2}

0 commit comments

Comments
 (0)