[REQUEST] Fix and add features in falling stuff (default)

lord_james
Member
 
Posts: 51
Joined: Sun Mar 11, 2012 22:06

[REQUEST] Fix and add features in falling stuff (default)

by lord_james » Sun Mar 18, 2012 03:25

While I was testing MT when I watched that grave and sand don't fall in the water. I have found in the code that only works with the node "air":

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

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?
Last edited by lord_james on Sun Mar 18, 2012 18:49, edited 1 time in total.
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Sun Mar 18, 2012 06:43

There is already a Pull Request on Github for the falling Thingy
+1 for the Thing in the Video
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

User avatar
Hackeridze
Member
 
Posts: 310
Joined: Thu Nov 03, 2011 13:35

by Hackeridze » Sun Mar 18, 2012 10:51

+1
My game: RTMG
GENTOO USER
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 54 guests

cron