Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
--
-- Some common functions
--
default.falling_node_names = {}
function nodeupdate_single(p)
n = minetest.env:get_node(p)
if default.falling_node_names[n.name] ~= nil then
p_bottom = {x=p.x, y=p.y-1, z=p.z}
n_bottom = minetest.env:get_node(p_bottom)
-- print(n_bottom)
if n_bottom.name == "air" then
minetest.env:remove_node(p)
minetest.env:add_entity(p, "default:falling_"..n.name)
nodeupdate(p)
end
end
end
function nodeupdate(p)
for x = -1,1 do
for y = -1,1 do
for z = -1,1 do
p2 = {x=p.x+x, y=p.y+y, z=p.z+z}
nodeupdate_single(p2)
end
end
end
end
--
-- Falling stuff
--
function default.register_falling_node(nodename, texture)
default.falling_node_names[nodename] = true
-- Override naming conventions for stuff like :default:falling_default:sand
minetest.register_entity(":default:falling_"..nodename, {
-- Static definition
physical = true,
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
visual = "cube",
textures = {texture,texture,texture,texture,texture,texture},
-- State
-- Methods
on_step = function(self, dtime)
-- Set gravity
self.object:setacceleration({x=0, y=-10, z=0})
-- Turn to actual sand when collides to ground or just move
local pos = self.object:getpos()
local bcp = {x=pos.x, y=pos.y-0.7, z=pos.z} -- Position of bottom center point
local bcn = minetest.env:get_node(bcp)
if bcn.name ~= "air" then
-- Turn to a sand node
local np = {x=bcp.x, y=bcp.y+1, z=bcp.z}
minetest.env:add_node(np, {name=nodename})
self.object:remove()
else
-- Do nothing
end
end
})
end
default.register_falling_node("default:sand", "default_sand.png")
default.register_falling_node("default:gravel", "default_gravel.png")
EDIT: It could be fixed with this code: https://github.com/bcmpinc/minetest/commit/4c366e1ca9a67d8ceb8ef1b89fe83610e63408e8
2º The new feature (an optional extra for some blocks) is the falling system in "Ace of spades" (only no flying nodes):
http://www.youtube.com/watch?feature=player_embedded&v=4hxuT-LSOl8
(2:00 to 2:25)
Could it be possible?