Skip to content

Commit

Permalink
Add minetest.spawn_falling_node(pos) (#5339)
Browse files Browse the repository at this point in the history
* Add minetest.spawn_falling_node(pos)

* lua_api.txt: Add minetest.spawn_falling_node(pos)

* Update minetest.spawn_falling_node(pos)
  • Loading branch information
zaoqi authored and nerzhul committed Mar 4, 2017
1 parent 6de83a2 commit c9ac722
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
14 changes: 14 additions & 0 deletions builtin/game/falling.lua
Expand Up @@ -118,6 +118,20 @@ local function spawn_falling_node(p, node)
end end
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 function drop_attached_node(p)
local nn = core.get_node(p).name local nn = core.get_node(p).name
core.remove_node(p) core.remove_node(p)
Expand Down
3 changes: 3 additions & 0 deletions doc/lua_api.txt
Expand Up @@ -2219,6 +2219,9 @@ and `minetest.auth_reload` call the authetification handler.
* Returns `true` if successful, `false` on failure (e.g. protected location) * Returns `true` if successful, `false` on failure (e.g. protected location)
* `minetest.punch_node(pos)` * `minetest.punch_node(pos)`
* Punch node with the same effects that a player would cause * 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)` * `minetest.find_nodes_with_meta(pos1, pos2)`
* Get a table of positions of nodes that have metadata within a region {pos1, pos2} * Get a table of positions of nodes that have metadata within a region {pos1, pos2}
Expand Down

0 comments on commit c9ac722

Please sign in to comment.