Page 1 of 1

Can this do this?

PostPosted: Sat Jun 02, 2012 17:41
by Jordach
What I am asking is: can a simple abm support using any node without having to do this:

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
nodenames = "default:dirt" "default:stone"
and so on?

PostPosted: Sat Jun 02, 2012 19:04
by mauvebic
perhaps if you tweaked builtins' register_node to add all the nodenames to a global array and use that?

PostPosted: Sat Jun 02, 2012 19:10
by mauvebic
like this (builtin/misc_register.lua)

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
ALLNODES = {}  -- new
function minetest.register_node(name, nodedef)
    nodedef.type = "node"
    minetest.register_item(name, nodedef)
    table.insert(ALLNODES, name)  -- new
end


then you have an array of all the nodenames to use with your abm

PostPosted: Sat Jun 02, 2012 19:14
by Jordach
So how would this work for nodenames = all ?

EDIT: Something like this:

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
minetest.register_abm(
        {nodenames =
        interval = 1,
        chance = 1,
        action = function(pos)
                minetest.env:add_node(pos, {name="default:dirt_with_grass"})
        end,
})


I am lost.

PostPosted: Sat Jun 02, 2012 19:28
by celeron55
What are you going to do with such an ABM?

Do you realize having a chance higher than, say, 1/1000 (to only randomly affect one out of a thousand nodes) will completely screw the functioning of the server by overloading it insanely?

PostPosted: Sat Jun 02, 2012 19:55
by Jordach
celeron55 wrote:What are you going to do with such an ABM?

Do you realize having a chance higher than, say, 1/1000 (to only randomly affect one out of a thousand nodes) will completely screw the functioning of the server by overloading it insanely?

It's not for that use, just as a complete test, that code is a placeholder for the time being.

EDIT: More thought - this also means, we would have to go through every node in madblocks, allowing it to either have stuff on it or not, with something like this, it should just look at the drawtype and go, yes you're a solid block, put snow on you.

PostPosted: Sun Jun 03, 2012 13:24
by mauvebic
well heres my winter abm:

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
            if CURRENT_SEASON == 1 then
                if node.name == 'madblocks:grass_autumn' or node.name == 'default:dirt_with_grass' or node.name == 'madblocks:grass_spring' then
                    minetest.env:add_node(pos,{type="node",name='madblocks:grass_winter'})
                elseif node.name == 'madblocks:leaves_autumn' or node.name == 'default:leaves' or node.name == 'madblocks:leaves_spring' then
                    minetest.env:add_node(pos,{type="node",name='madblocks:leaves_winter'})

                elseif node.name == 'default:desert_sand' then
                    above = minetest.env:get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z})
                    if above ~= nil and above.name == 'air' then
                        minetest.env:add_node(pos,{type="node",name='madblocks:desertsand_winter'})
                    end
                elseif node.name == 'default:sand' then
                    above = minetest.env:get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z})
                    if above ~= nil and above.name == 'air' then
                        minetest.env:add_node(pos,{type="node",name='madblocks:sand_winter'})
                    end
                elseif node.name == 'default:cactus' then
                    above = minetest.env:get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z})
                    if above ~= nil and above.name == 'air' then
                        minetest.env:add_node(pos,{type="node",name='madblocks:cactus_winter'})
                    end
                elseif node.name == 'default:water_source' then
                    above = minetest.env:get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z})
                    if above ~= nil and above.name == 'air' then
                        minetest.env:add_node(pos,{type="node",name='madblocks:ice_source'})
                    end
                elseif node.name == 'default:water_flowing' then
                    above = minetest.env:get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z})
                    if above ~= nil and above.name == 'air' then
                        minetest.env:add_node(pos,{type="node",name='madblocks:ice_flowing'})
                    end
                end


from what i understand, you want to use a < snow > node and place it ontop of anything thats solid and has air on top?

I think celerons' right having an ABM that works on such a massive scale would slow the game down. Hell i had to get rid of electricity in madblocks to make up the performance gobbled up by weather (and it still lags abit at the solstices)

heads up - If youre thinking of adding lua-entity falling snowflakes, dont test it out on a world you intend to keep, i ruined my last city that way lol

Hey celeron, is there a way we could add/change a texture to 'air' nodes to simlulate rain/snow? would be hella more easy than generating falling nodes or lua entities hehe. If we could change the skybox and cloud colors we could even simulate storms :-)