Skip to main content
Also watch on these platforms:

Rather than writing the same code over and over to use in multiple locations you can write a function and just call that, pass a few variables, and save yourself a lot of time.
Here is the sample function from in the video, you can find the desert life mod that I mentioned here.

 

function new_mod:wonderful_replace(nodename, pos, undernode)
    local under_pos = ({x=pos.x, y=pos.y-1, z=pos.z})
    local under_name = minetest.get_node_or_nil(under_pos)
    if under_name.name == undernode then
        minetest.set_node(under_pos, {name = nodename})
    end
end