mirror of
git://repo.or.cz/rocks.git
synced 2024-11-16 07:20:40 +01:00
Support for table as wherein param.
This commit is contained in:
parent
32ae5e4fb5
commit
14b16d55ca
2
ign.lua
2
ign.lua
|
@ -64,7 +64,7 @@ end
|
||||||
rocks.register_vein=regv
|
rocks.register_vein=regv
|
||||||
|
|
||||||
rocks.register_vein("default:nyancat",{
|
rocks.register_vein("default:nyancat",{
|
||||||
wherein="rocks:granite",
|
wherein={"rocks:granite"},
|
||||||
miny=-160, maxy=20,
|
miny=-160, maxy=20,
|
||||||
radius={ average=10, amplitude=4, frequency=8 },
|
radius={ average=10, amplitude=4, frequency=8 },
|
||||||
density=100,
|
density=100,
|
||||||
|
|
16
mapgen.lua
16
mapgen.lua
|
@ -26,7 +26,7 @@ rocksl.register_stratus=function(layer,name,param)
|
||||||
end
|
end
|
||||||
|
|
||||||
rocksl.register_vein=function(col,name,param)
|
rocksl.register_vein=function(col,name,param)
|
||||||
table.insert(col,{
|
local d={
|
||||||
primary=name,
|
primary=name,
|
||||||
wherein=param.wherein,
|
wherein=param.wherein,
|
||||||
miny=param.miny, maxy=param.maxy,
|
miny=param.miny, maxy=param.maxy,
|
||||||
|
@ -34,7 +34,8 @@ rocksl.register_vein=function(col,name,param)
|
||||||
density=(param.density or 1),
|
density=(param.density or 1),
|
||||||
rarity=param.rarity,
|
rarity=param.rarity,
|
||||||
secondary=(param.ores or {}),
|
secondary=(param.ores or {}),
|
||||||
})
|
}
|
||||||
|
table.insert(col,d)
|
||||||
end
|
end
|
||||||
|
|
||||||
rocksl.layergen=function(layer, minp, maxp, seed)
|
rocksl.layergen=function(layer, minp, maxp, seed)
|
||||||
|
@ -136,11 +137,14 @@ rocksl.veingen=function(veins,minp,maxp,seed)
|
||||||
},{x=(vrm*2)+1, y=(vrm*2)+1, z=(vrm*2)+1}
|
},{x=(vrm*2)+1, y=(vrm*2)+1, z=(vrm*2)+1}
|
||||||
)
|
)
|
||||||
local iterations_count= (vein.rarity*side_length)^3
|
local iterations_count= (vein.rarity*side_length)^3
|
||||||
|
-- Resolve node names to id's
|
||||||
iterations_count=iterations_count+(random:next(0,100)/100)
|
iterations_count=iterations_count+(random:next(0,100)/100)
|
||||||
local primary_ctx=minetest.get_content_id(vein.primary)
|
local primary_ctx=minetest.get_content_id(vein.primary)
|
||||||
for _,sec in pairs(vein.secondary) do sec.ctx=minetest.get_content_id(sec.ore) end
|
for _,sec in pairs(vein.secondary) do sec.ctx=minetest.get_content_id(sec.ore) end
|
||||||
local wherein_ctx=minetest.get_content_id(vein.wherein)
|
--old:local wherein_ctx=minetest.get_content_id(vein.wherein)
|
||||||
--print("vein "..vein.primary.." ic="..iterations_count.." p="..primary_ctx.." w="..wherein_ctx)
|
local wherein_set={}
|
||||||
|
for _,wi in pairs(vein.wherein) do wherein_set[minetest.get_content_id(wi)]=true end
|
||||||
|
--print("vein "..vein.primary.." ic="..iterations_count.." p="..primary_ctx)
|
||||||
for iteration=1, iterations_count do
|
for iteration=1, iterations_count do
|
||||||
local x0=minp.x+ random:next(0,side_length)
|
local x0=minp.x+ random:next(0,side_length)
|
||||||
local y0=minp.y+ random:next(0,side_length)
|
local y0=minp.y+ random:next(0,side_length)
|
||||||
|
@ -148,7 +152,7 @@ rocksl.veingen=function(veins,minp,maxp,seed)
|
||||||
local noise=noise_map:get3dMap_flat({x=x0-vrm, y=y0-vrm, z=z0-vrm})
|
local noise=noise_map:get3dMap_flat({x=x0-vrm, y=y0-vrm, z=z0-vrm})
|
||||||
local noise_ix=1
|
local noise_ix=1
|
||||||
local posi = area:index(x0, y0, z0)
|
local posi = area:index(x0, y0, z0)
|
||||||
if ignore_wherein or (nodes[posi]==wherein_ctx) then
|
if ignore_wherein or wherein_set[nodes[posi]] then
|
||||||
print("vein "..vein.primary.." @ "..x0..","..y0..","..z0.." vrm="..vrm)
|
print("vein "..vein.primary.." @ "..x0..","..y0..","..z0.." vrm="..vrm)
|
||||||
did_generate=1
|
did_generate=1
|
||||||
for x=-vrm, vrm do
|
for x=-vrm, vrm do
|
||||||
|
@ -157,7 +161,7 @@ rocksl.veingen=function(veins,minp,maxp,seed)
|
||||||
local posc = {x=x+x0,y=y+y0,z=z+z0}
|
local posc = {x=x+x0,y=y+y0,z=z+z0}
|
||||||
posi = area:index(posc.x, posc.y, posc.z)
|
posi = area:index(posc.x, posc.y, posc.z)
|
||||||
local nv=noise[noise_ix]
|
local nv=noise[noise_ix]
|
||||||
if (ignore_wherein or (nodes[posi]==wherein_ctx)) and (((x^2)+(y^2)+(z^2))<((vein.radius.average+nv)^2)) then
|
if (ignore_wherein or wherein_set[nodes[posi]]) and (((x^2)+(y^2)+(z^2))<((vein.radius.average+nv)^2)) then
|
||||||
nodes[posi]=primary_ctx
|
nodes[posi]=primary_ctx
|
||||||
local luck=random:next(0,99)
|
local luck=random:next(0,99)
|
||||||
for _,sec in pairs(vein.secondary) do
|
for _,sec in pairs(vein.secondary) do
|
||||||
|
|
11
skarn.lua
11
skarn.lua
|
@ -2,8 +2,9 @@
|
||||||
-- Skarn deposit
|
-- Skarn deposit
|
||||||
--
|
--
|
||||||
|
|
||||||
local CommonRarity=0.02
|
local CommonRarity=0.02 --too high... should be like 0.013
|
||||||
local CommonRadius=10
|
local CommonRadius=10
|
||||||
|
local CommonWherein={ "rocks:granite" }
|
||||||
|
|
||||||
minetest.register_node( "rocks:skarn", {
|
minetest.register_node( "rocks:skarn", {
|
||||||
description = S("Skarn"),
|
description = S("Skarn"),
|
||||||
|
@ -33,7 +34,7 @@ minetest.register_node( "rocks:skarn_malachyte", {
|
||||||
})
|
})
|
||||||
-- Chalcopyrite/Malachyte skarn mix
|
-- Chalcopyrite/Malachyte skarn mix
|
||||||
rocks.register_vein("rocks:skarn",{
|
rocks.register_vein("rocks:skarn",{
|
||||||
wherein="rocks:granite",
|
wherein=CommonWherein,
|
||||||
miny=-160, maxy=20,
|
miny=-160, maxy=20,
|
||||||
radius={ average=CommonRadius, amplitude=3, frequency=5 },
|
radius={ average=CommonRadius, amplitude=3, frequency=5 },
|
||||||
density=80, rarity=CommonRarity,
|
density=80, rarity=CommonRarity,
|
||||||
|
@ -62,7 +63,7 @@ minetest.register_node( "rocks:skarn_galena", {
|
||||||
})
|
})
|
||||||
-- Pb Zn skarn mix
|
-- Pb Zn skarn mix
|
||||||
rocks.register_vein("rocks:skarn",{
|
rocks.register_vein("rocks:skarn",{
|
||||||
wherein="rocks:granite",
|
wherein=CommonWherein,
|
||||||
miny=-160, maxy=20,
|
miny=-160, maxy=20,
|
||||||
radius={ average=CommonRadius, amplitude=3, frequency=5 },
|
radius={ average=CommonRadius, amplitude=3, frequency=5 },
|
||||||
density=80, rarity=CommonRarity,
|
density=80, rarity=CommonRarity,
|
||||||
|
@ -84,7 +85,7 @@ minetest.register_node( "rocks:skarn_magnetite", {
|
||||||
})
|
})
|
||||||
-- Fe skarn mix
|
-- Fe skarn mix
|
||||||
rocks.register_vein("rocks:skarn",{
|
rocks.register_vein("rocks:skarn",{
|
||||||
wherein="rocks:granite",
|
wherein=CommonWherein,
|
||||||
miny=-160, maxy=20,
|
miny=-160, maxy=20,
|
||||||
radius={ average=CommonRadius, amplitude=3, frequency=5 },
|
radius={ average=CommonRadius, amplitude=3, frequency=5 },
|
||||||
density=80, rarity=CommonRarity,
|
density=80, rarity=CommonRarity,
|
||||||
|
@ -112,7 +113,7 @@ minetest.register_node( "rocks:vermiculite", {
|
||||||
})
|
})
|
||||||
-- magnesite/vermiculite skarn mix
|
-- magnesite/vermiculite skarn mix
|
||||||
rocks.register_vein("rocks:skarn",{
|
rocks.register_vein("rocks:skarn",{
|
||||||
wherein="rocks:granite",
|
wherein=CommonWherein,
|
||||||
miny=-160, maxy=20,
|
miny=-160, maxy=20,
|
||||||
radius={ average=CommonRadius, amplitude=3, frequency=5 },
|
radius={ average=CommonRadius, amplitude=3, frequency=5 },
|
||||||
density=80, rarity=CommonRarity,
|
density=80, rarity=CommonRarity,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user