Page 1 of 1

Ore generation

PostPosted: Sun Dec 04, 2011 08:11
by Evrim
I wonder if doing this is possible as me and a friend modded diamonds, chisels and diamonds tools

PostPosted: Sun Dec 04, 2011 12:28
by sdzen
I hope it is, otherwise I wont be able to add emeralds

PostPosted: Sun Dec 04, 2011 16:43
by Evrim
The thing is that everything is ready and if we can't find a way to do it all the work will be nothing

PostPosted: Sun Dec 04, 2011 17:39
by celeron55
It is somewhat doable, but not very fancily. Off the top of my head without any testing:

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_on_generated(function(minp, maxp))
    local amount = math.random(0, 50)
    for a=0,amount do
        local pos = {
            x = math.random(minp.x, maxp.x),
            y = math.random(minp.y, maxp.y),
            z = math.random(minp.z, maxp.z),
        }
        for i=-1,1 do
            for j=-1,1 do
                for k=-1,1 do
                    if math.random() > 0.2 then
                        continue
                    end
                    local p = {x=pos.x+i, y=pos.y+j, z=pos.z+k}
                    local n = minetest.env:get_node(p)
                    if n.name == "default:stone" then
                        minetest.env:add_node(p, {name="yourmod:stone_with_yourmineral"})
                    end
                end
            end
        end
    end
end

PostPosted: Sun Dec 04, 2011 19:05
by Evrim
I got some unexpected paranthesis error...

PostPosted: Sun Feb 19, 2012 03:51
by IPushButton2653
celeron55 wrote:It is somewhat doable, but not very fancily. Off the top of my head without any testing:

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_on_generated(function(minp, maxp))
    local amount = math.random(0, 50)
    for a=0,amount do
        local pos = {
            x = math.random(minp.x, maxp.x),
            y = math.random(minp.y, maxp.y),
            z = math.random(minp.z, maxp.z),
        }
        for i=-1,1 do
            for j=-1,1 do
                for k=-1,1 do
                    if math.random() > 0.2 then
                        continue
                    end
                    local p = {x=pos.x+i, y=pos.y+j, z=pos.z+k}
                    local n = minetest.env:get_node(p)
                    if n.name == "default:stone" then
                        minetest.env:add_node(p, {name="yourmod:stone_with_yourmineral"})
                    end
                end
            end
        end
    end
end

Darn, I should've looked before I posted anything earlier