mirror of
git://repo.or.cz/rocks.git
synced 2025-08-05 01:40:32 +02:00
Compare commits
14 Commits
last-usabl
...
master
Author | SHA1 | Date | |
---|---|---|---|
2b7e20b4bb | |||
16a9a079d9 | |||
f9d6fbdcea | |||
90718a30ee | |||
1b318ccedc | |||
a7278f26d8 | |||
4b1d998116 | |||
d01049f0d0 | |||
0b0deec9a0 | |||
9b9419f2eb | |||
a9f2272127 | |||
f4ba640dcf | |||
8ace387da3 | |||
945be335d8 |
2
a.txt
2
a.txt
@ -1,4 +1,4 @@
|
|||||||
Geological layer generator for [Minetest] "rocks"
|
Geological layer generator for Minetest "rocks" {wip}
|
||||||
=============
|
=============
|
||||||
|
|
||||||
Aim of this mod is to replace all generic stone (default:stone) and
|
Aim of this mod is to replace all generic stone (default:stone) and
|
||||||
|
0
depositgen/depends.txt
Normal file
0
depositgen/depends.txt
Normal file
50
depositgen/init.lua
Normal file
50
depositgen/init.lua
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
depositgen={}
|
||||||
|
local l={}
|
||||||
|
depositgen.l=l
|
||||||
|
|
||||||
|
l.print=function(text)
|
||||||
|
minetest.log("action","[depositgen] "..text)
|
||||||
|
end
|
||||||
|
|
||||||
|
l.print("mod initializing")
|
||||||
|
|
||||||
|
local modpath=minetest.get_modpath(minetest.get_current_modname())
|
||||||
|
|
||||||
|
l.OnGenerate={}
|
||||||
|
l.OnInit={}
|
||||||
|
l.ToResolve={}
|
||||||
|
|
||||||
|
local includes={
|
||||||
|
"utils","pipes","veins"
|
||||||
|
}
|
||||||
|
|
||||||
|
minetest.register_on_generated(function(minp,maxp,seed)
|
||||||
|
l.print("on generated")
|
||||||
|
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||||
|
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
||||||
|
local pr=PseudoRandom(seed)
|
||||||
|
local data=vm:get_data()
|
||||||
|
local mgc={minp=minp,maxp=maxp,pr=pr,data=data,area=area}
|
||||||
|
for i=1, #l.OnGenerate do
|
||||||
|
l.OnGenerate[i](mgc)
|
||||||
|
end
|
||||||
|
vm:set_data(data)
|
||||||
|
vm:write_to_map()
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_on_mapgen_init(function(mapgen_params)
|
||||||
|
-- todo: disable caves and ores
|
||||||
|
-- todo: sort layers
|
||||||
|
--Resolve all mapgen nodes to content ids
|
||||||
|
l.print("Resolving node names")
|
||||||
|
for index,i in pairs(l.ToResolve) do
|
||||||
|
i.id=minetest.get_content_id(i.name)
|
||||||
|
i.name=nil --free some memory
|
||||||
|
end
|
||||||
|
l.print("running mapgen initialization tasks")
|
||||||
|
for _,i in pairs(l.OnInit) do
|
||||||
|
i(mapgen_params)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
for _,s in pairs(includes) do dofile(modpath.."/"..s..".lua") end
|
115
depositgen/pipes.lua
Normal file
115
depositgen/pipes.lua
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
-- experimental pipe generator
|
||||||
|
local l=depositgen.l
|
||||||
|
local print=l.print
|
||||||
|
|
||||||
|
-- the public table of registered pipes
|
||||||
|
depositgen.pipes={}
|
||||||
|
local regs=depositgen.pipes
|
||||||
|
|
||||||
|
depositgen.register_pipe= function(descr)
|
||||||
|
local pipe={
|
||||||
|
ymin=(descr.ymin or -10000),
|
||||||
|
ymax=(descr.ymax or 200),
|
||||||
|
scarcity=descr.scarcity,
|
||||||
|
width=descr.width-1,
|
||||||
|
content={ name=descr.content },
|
||||||
|
scatter={}
|
||||||
|
}
|
||||||
|
table.insert(depositgen.l.ToResolve,pipe.content)
|
||||||
|
for _,sc in pairs(descr.scatter) do
|
||||||
|
local psc={
|
||||||
|
scarcity=sc.scarcity,
|
||||||
|
size=(sc.size or pipe.width),
|
||||||
|
density=sc.density,
|
||||||
|
content={ name=sc.content }
|
||||||
|
}
|
||||||
|
table.insert(depositgen.l.ToResolve,psc.content)
|
||||||
|
table.insert(pipe.scatter,psc)
|
||||||
|
end
|
||||||
|
return table.insert(regs,pipe)
|
||||||
|
end
|
||||||
|
|
||||||
|
do
|
||||||
|
local sample_pipe_def={
|
||||||
|
ymin=-200, ymax=-6,
|
||||||
|
scarcity=80,
|
||||||
|
width=4,
|
||||||
|
content="default:glass",
|
||||||
|
scatter={
|
||||||
|
{ scarcity=7, density=4, content="default:mese", size=2 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--depositgen.register_pipe(sample_pipe_def)
|
||||||
|
end
|
||||||
|
|
||||||
|
depositgen.l.ToResolve.air={name="air"}
|
||||||
|
|
||||||
|
local function generate(mgc)
|
||||||
|
local t1 = os.clock()
|
||||||
|
|
||||||
|
local data = mgc.data
|
||||||
|
local area = mgc.area
|
||||||
|
local pr=mgc.pr
|
||||||
|
local minp,maxp=mgc.minp,mgc.maxp
|
||||||
|
local chunksizer = maxp.x - minp.x + 1
|
||||||
|
local chunksize = chunksizer + 1
|
||||||
|
local pmapsize = {x = chunksize, y = chunksize, z = chunksize}
|
||||||
|
local minpxz = {x = minp.x, y = minp.z}
|
||||||
|
|
||||||
|
for _,descr in pairs(regs) do
|
||||||
|
local numpipes_raw=(chunksize/descr.scarcity)
|
||||||
|
local numpipes = math.floor(numpipes_raw + (pr:next(0,99)/100))
|
||||||
|
|
||||||
|
for vc=1, numpipes do
|
||||||
|
local pointA=l.rndvector(mgc)
|
||||||
|
local pointB=l.rndvector(mgc)
|
||||||
|
local pointC=l.rndvector(mgc)
|
||||||
|
local step=(1.8)/(vector.distance(pointA,pointB)+vector.distance(pointB,pointC))
|
||||||
|
|
||||||
|
for t=0, 1, step do
|
||||||
|
local p=vector.multiply(pointA,(1-t)^2)
|
||||||
|
local di
|
||||||
|
p=vector.add(p, vector.multiply(pointB,2*t*(1-t)) )
|
||||||
|
p=vector.add(p, vector.multiply(pointC,t*t) )
|
||||||
|
p=vector.round(p)
|
||||||
|
local radiusp=math.floor(descr.width/2)
|
||||||
|
local radiusn=-descr.width+radiusp
|
||||||
|
--<scatter>
|
||||||
|
for _,ore in pairs(descr.scatter) do
|
||||||
|
if pr:next(0,ore.scarcity)==0 then
|
||||||
|
local ocx=pr:next(radiusn,radiusp)
|
||||||
|
local ocy=pr:next(radiusn,radiusp)
|
||||||
|
local ocz=pr:next(radiusn,radiusp)
|
||||||
|
for y=ocy-ore.size, ocy+ore.size do
|
||||||
|
for x=ocx-ore.size, ocx+ore.size do
|
||||||
|
for z=ocz-ore.size, ocz+ore.size do
|
||||||
|
if pr:next(0,ore.density)==0 then
|
||||||
|
di=area:index(p.x+x,p.y+y,p.z+z)
|
||||||
|
if data[di]==depositgen.l.ToResolve.air.id then
|
||||||
|
data[di]=ore.content.id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end end end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
--</scatter>
|
||||||
|
--<brush>
|
||||||
|
for y= radiusn, radiusp do
|
||||||
|
for x= radiusn, radiusp do
|
||||||
|
for z= radiusn, radiusp do
|
||||||
|
di=area:index(p.x+x,p.y+y,p.z+z)
|
||||||
|
if data[di]==depositgen.l.ToResolve.air.id then
|
||||||
|
data[di]=descr.content.id
|
||||||
|
end
|
||||||
|
end end end
|
||||||
|
--</brush>
|
||||||
|
--brush(data,area,p,descr.radius,content,descr.scatter,orepr)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end --</apipe>
|
||||||
|
|
||||||
|
l.print("pipes "..math.ceil((os.clock() - t1) * 1000).." ms ")
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(depositgen.l.OnGenerate,generate)
|
16
depositgen/utils.lua
Normal file
16
depositgen/utils.lua
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
function depositgen.l.SpawnCluster(mgc,pos,wherein,size,content,density)
|
||||||
|
for y=pos.y-size, pos.y+size do
|
||||||
|
for x=pos.x-size, pos.x+size do
|
||||||
|
for z=pos.z-size, pos.z+size do
|
||||||
|
if mgc.pr:next(0,density)==0 then
|
||||||
|
di=mgc.area:index(x,y,z)
|
||||||
|
if mgc.data[di]==wherein then
|
||||||
|
mgc.data[di]=content
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end end end
|
||||||
|
end
|
||||||
|
function depositgen.l.rndvector(mgc)
|
||||||
|
local chunksizer = mgc.maxp.x - mgc.minp.x + 1
|
||||||
|
return vector.new(mgc.pr:next(0,chunksizer)+mgc.minp.x,mgc.pr:next(0,chunksizer)+mgc.minp.y,mgc.pr:next(0,chunksizer)+mgc.minp.z)
|
||||||
|
end
|
101
depositgen/veins.lua
Normal file
101
depositgen/veins.lua
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
-- experimental fast vein generator
|
||||||
|
|
||||||
|
local l=depositgen.l
|
||||||
|
local print=l.print
|
||||||
|
|
||||||
|
-- the public table of registered veins
|
||||||
|
depositgen.veins={}
|
||||||
|
local regs=depositgen.veins
|
||||||
|
|
||||||
|
depositgen.register_vein= function(descr)
|
||||||
|
local vein={
|
||||||
|
ymin=(descr.ymin or -10000),
|
||||||
|
ymax=(descr.ymax or 200),
|
||||||
|
scarcity=descr.scarcity,
|
||||||
|
content={ name=descr.content },
|
||||||
|
scatter={}
|
||||||
|
}
|
||||||
|
table.insert(depositgen.l.ToResolve,vein.content)
|
||||||
|
for _,sc in pairs(descr.scatter) do
|
||||||
|
local psc={
|
||||||
|
scarcity=sc.scarcity,
|
||||||
|
size=(sc.size or vein.width),
|
||||||
|
density=sc.density,
|
||||||
|
content={ name=sc.content }
|
||||||
|
}
|
||||||
|
table.insert(depositgen.l.ToResolve,psc.content)
|
||||||
|
table.insert(vein.scatter,psc)
|
||||||
|
end
|
||||||
|
return table.insert(regs,vein)
|
||||||
|
end
|
||||||
|
|
||||||
|
do
|
||||||
|
local sample_vein_def={
|
||||||
|
ymin=-200, ymax=-6,
|
||||||
|
scarcity=80,
|
||||||
|
content="default:dirt",
|
||||||
|
scatter={
|
||||||
|
{ scarcity=7, density=4, content="default:mese", size=2 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
depositgen.register_vein(sample_vein_def)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function generate(mgc)
|
||||||
|
local t1 = os.clock()
|
||||||
|
local data = mgc.data
|
||||||
|
local area = mgc.area
|
||||||
|
local pr=mgc.pr
|
||||||
|
|
||||||
|
local chunksizer = mgc.maxp.x - mgc.minp.x + 1
|
||||||
|
local chunksize = chunksizer + 1
|
||||||
|
local pmapsize = {x = chunksize, y = chunksize, z = chunksize}
|
||||||
|
local minpxz = {x = mgc.minp.x, y = mgc.minp.z}
|
||||||
|
|
||||||
|
for _,descr in pairs(regs) do
|
||||||
|
local num = math.floor( (chunksize/descr.scarcity) + (pr:next(0,99)/100) )
|
||||||
|
for vc=1, num do
|
||||||
|
|
||||||
|
local A=l.rndvector(mgc)
|
||||||
|
local B=l.rndvector(mgc)
|
||||||
|
local C=l.rndvector(mgc)
|
||||||
|
local D=l.rndvector(mgc)
|
||||||
|
local l1=vector.distance(A,C)+vector.distance(C,B)
|
||||||
|
local l2=vector.distance(A,D)+vector.distance(D,B)
|
||||||
|
local step=2/math.max(l1,l2)
|
||||||
|
for t=0, 1, step do
|
||||||
|
local P=vector.multiply(A,(1-t)^2)
|
||||||
|
P=vector.add(P, vector.multiply(B,t*t) )
|
||||||
|
local Q=vector.add(P, vector.multiply(D,2*t*(1-t)) )
|
||||||
|
P=vector.add(P, vector.multiply(C,2*t*(1-t)) )
|
||||||
|
local step2=1/vector.distance(P,Q)
|
||||||
|
for u=0, 1, step2 do
|
||||||
|
local R=vector.add(vector.multiply(P,(1-u)), vector.multiply(Q,u) )
|
||||||
|
--<brush>
|
||||||
|
local di=area:indexp(vector.round(R))
|
||||||
|
if data[di] then
|
||||||
|
data[di]=descr.content.id
|
||||||
|
end
|
||||||
|
--</brush>
|
||||||
|
end
|
||||||
|
end
|
||||||
|
--<ores>
|
||||||
|
local cluster=descr.scatter[1]
|
||||||
|
for xxx=1, 5 do
|
||||||
|
local t=pr:next(0,100)/100
|
||||||
|
local u=pr:next(0,100)/100
|
||||||
|
local P=vector.multiply(A,(1-t)^2)
|
||||||
|
P=vector.add(P, vector.multiply(B,t*t) )
|
||||||
|
local Q=vector.add(P, vector.multiply(D,2*t*(1-t)) )
|
||||||
|
P=vector.add(P, vector.multiply(C,2*t*(1-t)) )
|
||||||
|
local R=vector.add(vector.multiply(P,(1-u)), vector.multiply(Q,u) )
|
||||||
|
l.SpawnCluster(mgc,vector.round(R),l.ToResolve.air.id,cluster.size,cluster.content.id,cluster.density)
|
||||||
|
end
|
||||||
|
--</ores>
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
print("vein "..math.ceil((os.clock() - t1) * 1000).." ms ")
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(depositgen.l.OnGenerate,generate)
|
22
how.txt
Normal file
22
how.txt
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
I see that the state this mod is now is horrible. Now, as I passed my final
|
||||||
|
exams, i decided to spend more time on this. Since I cannot write a
|
||||||
|
complete geological simulator, I decided on the following strategy:
|
||||||
|
|
||||||
|
1. Under like 5km generate only igneous rocks.
|
||||||
|
2. Abowe that generate sandstone, that will serve as placeholder for more rocks.
|
||||||
|
3. Generate a fixed amout of layers of rocks there.
|
||||||
|
- some igneous layers could represent lava spills
|
||||||
|
- including metamorphic rocks
|
||||||
|
4. Shift everything around (possibly multiple times) to simulate faults.
|
||||||
|
5. Create some intrusions (name?) and underground volcanic activity.
|
||||||
|
6. Create some veins.
|
||||||
|
|
||||||
|
Using 2d noise as heightmap has one notable advantage: Looping over 80*80
|
||||||
|
nodes is faster than 80*80*80.
|
||||||
|
|
||||||
|
Minecraft mods I inspire from: Geologica, SGU bettergeo, geocraft.
|
||||||
|
|
||||||
|
Doing a complete geological mapgen could be possible too: Start with plate
|
||||||
|
tectonics, deposit rock in layer on top of each other, do some faults and
|
||||||
|
folding inbetween, put soil on top. This could produce an interesting
|
||||||
|
landscape.
|
@ -1 +0,0 @@
|
|||||||
default
|
|
205
rocks/gensed.lua
205
rocks/gensed.lua
@ -1,205 +0,0 @@
|
|||||||
-- experimental sedimentary layer generator
|
|
||||||
|
|
||||||
local np_elv = {
|
|
||||||
offset = 0, octaves = 2, persist = 0.4,
|
|
||||||
scale = 8,
|
|
||||||
spread = {x=25, y=25, z=25},
|
|
||||||
seed = -546,
|
|
||||||
}
|
|
||||||
local np_typ1 = {
|
|
||||||
offset = 0, octaves = 2, persist = 0.33,
|
|
||||||
scale = 1,
|
|
||||||
spread = {x=50, y=50, z=50},
|
|
||||||
seed = -5500,
|
|
||||||
}
|
|
||||||
local np_typ2 = {
|
|
||||||
offset = 0, octaves = 2, persist = 0.33,
|
|
||||||
scale = 1,
|
|
||||||
spread = {x=70, y=70, z=70},
|
|
||||||
seed = -5472,
|
|
||||||
}
|
|
||||||
local np_vc = {
|
|
||||||
offset = 0, octaves = 2, persist = 0.33,
|
|
||||||
scale = 1,
|
|
||||||
spread = {x=100, y=100, z=100},
|
|
||||||
seed = 749,
|
|
||||||
}
|
|
||||||
local np_sp = {
|
|
||||||
offset = 0, octaves = 2, persist = 0.33,
|
|
||||||
scale = 1,
|
|
||||||
spread = {x=150, y=150, z=150},
|
|
||||||
seed = -1284,
|
|
||||||
}
|
|
||||||
|
|
||||||
local stats
|
|
||||||
stats={ total=0 }
|
|
||||||
|
|
||||||
rocksl.gensed = function (minp, maxp, seed, vm, area)
|
|
||||||
local t1 = os.clock()
|
|
||||||
local data = vm:get_data()
|
|
||||||
|
|
||||||
local chunksize = maxp.x - minp.x + 1
|
|
||||||
local pmapsize = {x = chunksize, y = chunksize, z = chunksize}
|
|
||||||
local minpxz = {x = minp.x, y = minp.z}
|
|
||||||
local c_stone= minetest.get_content_id("default:stone")
|
|
||||||
local c_dwg= c_stone
|
|
||||||
|
|
||||||
local sla = {
|
|
||||||
{min=18, sd=169},
|
|
||||||
{min=9, sd=324},
|
|
||||||
{min=0, sd=-230},
|
|
||||||
{min=-6, sd=850},
|
|
||||||
{min=-12, sd=-643},
|
|
||||||
{min=-18, sd=0},
|
|
||||||
}
|
|
||||||
if minp.y<(sla[#sla].min-10) then return end
|
|
||||||
local biomes = {
|
|
||||||
lava={ mod="default" },
|
|
||||||
nyancat={ mod="default" },
|
|
||||||
wood={ mod="default" },
|
|
||||||
gravel={ mod="default" },
|
|
||||||
sand={ mod="default" },
|
|
||||||
sandstone={ mod="default" },
|
|
||||||
clay={ mod="default" },
|
|
||||||
claystone={ mod="rocks" },
|
|
||||||
slate={ mod="rocks" },
|
|
||||||
conglomerate={ mod="rocks" },
|
|
||||||
mudstone={ mod="rocks" },
|
|
||||||
limestone={ mod="rocks" },
|
|
||||||
blackcoal={ mod="rocks" },
|
|
||||||
lignite={ mod="rocks" },
|
|
||||||
anthracite={ mod="rocks" },
|
|
||||||
}
|
|
||||||
for k,v in pairs(biomes) do
|
|
||||||
v.ctx=v.ctx or minetest.get_content_id(v.mod..":"..k)
|
|
||||||
if stats and (stats[k]==nil) then stats[k]=0 end
|
|
||||||
end
|
|
||||||
n_elv= minetest.get_perlin_map(np_elv, pmapsize) : get2dMap_flat(minp)
|
|
||||||
|
|
||||||
local generated
|
|
||||||
local nixz= 0
|
|
||||||
local nixyz= 0
|
|
||||||
for z=minp.z, maxp.z do for x=minp.x, maxp.x do
|
|
||||||
nixz= nixz+1
|
|
||||||
-- loop
|
|
||||||
local bi
|
|
||||||
local li
|
|
||||||
for y=maxp.y, minp.y, -1 do
|
|
||||||
nixyz=nixyz+1
|
|
||||||
local di=area:index(x,y,z)
|
|
||||||
local yn=y +n_elv[nixz]
|
|
||||||
if (data[di]==c_stone) and ((not bi)or(yn<sla[li].min)) then
|
|
||||||
-- go to deeper layer
|
|
||||||
if not li then li=1 end
|
|
||||||
while (li<=#sla)and(sla[li].min>yn) do
|
|
||||||
li=li+1
|
|
||||||
end
|
|
||||||
-- create noises for this layer
|
|
||||||
if li>#sla then break end -- break y loop if too low
|
|
||||||
if (not sla[li].n_tp1) then
|
|
||||||
local altminpxz={ x=minp.x+sla[li].sd,
|
|
||||||
y=minp.z-sla[li].sd}
|
|
||||||
sla[li].n_tp1= minetest.get_perlin_map(np_typ1, pmapsize) : get2dMap_flat(altminpxz)
|
|
||||||
sla[li].n_tp2= minetest.get_perlin_map(np_typ2, pmapsize) : get2dMap_flat(altminpxz)
|
|
||||||
sla[li].n_vc= minetest.get_perlin_map(np_vc, pmapsize) : get2dMap_flat(altminpxz)
|
|
||||||
sla[li].n_sp= minetest.get_perlin_map(np_sp, pmapsize) : get2dMap_flat(altminpxz)
|
|
||||||
end
|
|
||||||
-- BEGIN geome resolution
|
|
||||||
local vcva= math.abs(sla[li].n_vc[nixz])
|
|
||||||
local vcv= sla[li].n_vc[nixz]
|
|
||||||
local spv= sla[li].n_sp[nixz]
|
|
||||||
local tp=1 --=particulates, 2=biosediments, 3=chemosediments, 4=vulcanosediments
|
|
||||||
if sla[li].n_tp1[nixz]>0.2 then tp=2
|
|
||||||
if sla[li].n_tp2[nixz]>0.81 then tp=4 end
|
|
||||||
elseif sla[li].n_tp2[nixz]>0.76 then tp=3 end
|
|
||||||
|
|
||||||
if tp==1 then
|
|
||||||
-- particulates
|
|
||||||
if vcva>0.453 then
|
|
||||||
-- clay-(0,stone,slate)
|
|
||||||
if spv>0.23 then bi="slate"
|
|
||||||
elseif spv>-0.2 then bi="claystone"
|
|
||||||
else bi="clay" end
|
|
||||||
elseif vcva>0.4 then
|
|
||||||
bi="mudstone"
|
|
||||||
elseif vcva>0.2 then
|
|
||||||
-- sand-(0,stone)
|
|
||||||
if spv>-0.3 then bi="sandstone" else bi="sand" end
|
|
||||||
else
|
|
||||||
-- gravel/conglomerate
|
|
||||||
if spv>-0.34 then bi="conglomerate" else bi="gravel" end
|
|
||||||
-- breccia?
|
|
||||||
end
|
|
||||||
elseif tp==2 then
|
|
||||||
-- biosediments
|
|
||||||
if vcv>0.05 then
|
|
||||||
bi="limestone"
|
|
||||||
elseif vcv>-0.1 then
|
|
||||||
--uhlia
|
|
||||||
if spv>0.7 then bi="anthracite"
|
|
||||||
elseif spv>0 then bi="blackcoal"
|
|
||||||
else bi="lignite" end
|
|
||||||
else
|
|
||||||
--ine
|
|
||||||
bi="wood"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- END geome resolution
|
|
||||||
|
|
||||||
if not bi then bi="nyancat" end
|
|
||||||
generated=true
|
|
||||||
end
|
|
||||||
if (data[di]==c_stone) then
|
|
||||||
data[di]=biomes[bi].ctx
|
|
||||||
if stats then stats.total=stats.total+1 stats[bi]=stats[bi]+1 end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end end
|
|
||||||
if generated then
|
|
||||||
vm:set_data(data)
|
|
||||||
if stats then for k,v in pairs(stats) do print("stat: "..k..": "..((v/stats.total)*100).."%") end end
|
|
||||||
else
|
|
||||||
print("no sed layer y="..minp.y)
|
|
||||||
end
|
|
||||||
minetest.log("action", "rocks/gensed/ "..math.ceil((os.clock() - t1) * 1000).." ms ")
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_node( "rocks:slate", {
|
|
||||||
description = S("Slate"),
|
|
||||||
tiles = { "rocks_Slate.png" },
|
|
||||||
is_ground_content = true, sounds = default.node_sound_dirt_defaults(),
|
|
||||||
groups = {cracky=3},
|
|
||||||
})
|
|
||||||
minetest.register_node( "rocks:claystone", {
|
|
||||||
description = S("Claystone"),
|
|
||||||
tiles = { "rocks_claystone.png" },
|
|
||||||
is_ground_content = true, sounds = default.node_sound_dirt_defaults(),
|
|
||||||
groups = {crumbly=1, cracky=3},
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node( "rocks:conglomerate", {
|
|
||||||
description = S("Conglomerate"),
|
|
||||||
tiles = { "rocks_conglomerate.png" },
|
|
||||||
is_ground_content = true, sounds = default.node_sound_dirt_defaults(),
|
|
||||||
groups = {crumbly=3},
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node( "rocks:lignite", {
|
|
||||||
description = S("Lignite coal"),
|
|
||||||
tiles = { "rocks_Mudstone.png^rocks_lignite.png" },
|
|
||||||
is_ground_content = true,
|
|
||||||
groups = {crumbly=3},
|
|
||||||
})
|
|
||||||
minetest.register_node( "rocks:blackcoal", {
|
|
||||||
description = S("Black coal"),
|
|
||||||
tiles = { "rocks_Mudstone.png^default_mineral_coal.png" },
|
|
||||||
is_ground_content = true,
|
|
||||||
groups = {crumbly=3},
|
|
||||||
})
|
|
||||||
minetest.register_node( "rocks:anthracite", {
|
|
||||||
description = S("Anthracite coal"),
|
|
||||||
tiles = { "rocks_Mudstone.png^rocks_anthracite.png" },
|
|
||||||
is_ground_content = true,
|
|
||||||
groups = {crumbly=3},
|
|
||||||
})
|
|
143
rocks/ign.lua
143
rocks/ign.lua
@ -1,143 +0,0 @@
|
|||||||
--
|
|
||||||
-- Igneous Layer
|
|
||||||
--
|
|
||||||
|
|
||||||
-- Basalt Ex/Mafic hard same as diorite, byt limit=0.5
|
|
||||||
minetest.register_node( "rocks:basalt", {
|
|
||||||
description = S("Basalt"),
|
|
||||||
tiles = { "rocks_Basalt.png" },
|
|
||||||
groups = {cracky=3, stone=1},
|
|
||||||
is_ground_content = true, sounds = default.node_sound_stone_defaults(),
|
|
||||||
})
|
|
||||||
minetest.register_alias("mapgen_stone", "rocks:basalt")
|
|
||||||
|
|
||||||
-- ^ does not work. Seems we can not overwrite an alias.
|
|
||||||
-- If the alias in default/mapgen.lua is deleted, this works.
|
|
||||||
|
|
||||||
-- more rock defs
|
|
||||||
minetest.register_node( "rocks:granite", {
|
|
||||||
description = S("Granite"),
|
|
||||||
tiles = { "rocks_wgr.png" },
|
|
||||||
is_ground_content = true, sounds = default.node_sound_stone_defaults(),
|
|
||||||
groups = {cracky=3, stone=1},
|
|
||||||
})
|
|
||||||
minetest.register_node( "rocks:diorite", {
|
|
||||||
description = S("Diorite"),
|
|
||||||
tiles = { "rocks_Diorite.png" },
|
|
||||||
groups = {cracky=3, stone=1},
|
|
||||||
is_ground_content = true, sounds = default.node_sound_stone_defaults(),
|
|
||||||
})
|
|
||||||
minetest.register_node( "rocks:gabbro", {
|
|
||||||
description = S("Gabbro"),
|
|
||||||
tiles = { "rocks_Gabbro.png" },
|
|
||||||
groups = {cracky=3, stone=1},
|
|
||||||
is_ground_content = true, sounds = default.node_sound_stone_defaults(),
|
|
||||||
})
|
|
||||||
|
|
||||||
local reg=function(name,param)
|
|
||||||
minetest.register_ore({
|
|
||||||
ore = name,
|
|
||||||
wherein= param.inr,
|
|
||||||
ore_type = "scatter",
|
|
||||||
clust_scarcity = 10^3,
|
|
||||||
clust_num_ores = 20^3,
|
|
||||||
clust_size = 20,
|
|
||||||
height_min = -31000,
|
|
||||||
height_max = 28,
|
|
||||||
noise_threshhold=param.treshold,
|
|
||||||
noise_params={
|
|
||||||
offset = 0, scale = 1, octaves = 1, persist = 0.5,
|
|
||||||
spread = {x=param.spread, y=param.height, z=param.spread},
|
|
||||||
seed=rocksl.GetNextSeed(),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end
|
|
||||||
rocks.register_igneous_stratus=reg
|
|
||||||
|
|
||||||
-- vein stuff
|
|
||||||
|
|
||||||
local regv=function(name,param)
|
|
||||||
minetest.register_ore({
|
|
||||||
ore = name,
|
|
||||||
wherein= param.wherein,
|
|
||||||
ore_type = "blob",
|
|
||||||
clust_scarcity = param.rarity^3,
|
|
||||||
clust_num_ores = 8,
|
|
||||||
clust_size = param.radius.average*2,
|
|
||||||
height_min = -31000,
|
|
||||||
height_max = 50,
|
|
||||||
noise_threshhold = 0.5, --< determined experimentally
|
|
||||||
noise_params={
|
|
||||||
offset = 1-param.radius.amplitude, scale = param.radius.amplitude, octaves = 3, persist = 0.5,
|
|
||||||
spread = {x=param.radius.frequency, y=param.radius.frequency, z=param.radius.frequency},
|
|
||||||
seed=rocksl.GetNextSeed(),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
rocks.register_vein=regv
|
|
||||||
|
|
||||||
local np_layer = {
|
|
||||||
offset = 0, octaves = 3, persist = 0.46,
|
|
||||||
scale = 30,
|
|
||||||
spread = {x=500, y=500, z=500},
|
|
||||||
seed = -5500,
|
|
||||||
}
|
|
||||||
local np_intr = {
|
|
||||||
octaves = 3, persist = 0.46,
|
|
||||||
scale = 20,
|
|
||||||
offset = -15,
|
|
||||||
spread = {x=100, y=100, z=100},
|
|
||||||
seed = 3740,
|
|
||||||
}
|
|
||||||
|
|
||||||
--minetest.register_on_generated( function( minp, maxp, seed )
|
|
||||||
rocksl.genign=function(minp,maxp,seed, vm, area)
|
|
||||||
local t1 = os.clock()
|
|
||||||
local data = vm:get_data()
|
|
||||||
|
|
||||||
local chunksize = maxp.x - minp.x + 1
|
|
||||||
local pmapsize = {x = chunksize, y = chunksize, z = 1}
|
|
||||||
local pmapminpxz = {x = minp.x, y = minp.z}
|
|
||||||
local c_stone= minetest.get_content_id("default:stone")
|
|
||||||
local layers= {
|
|
||||||
{ min=-100, node="rocks:granite" },
|
|
||||||
{ min=-240, node="rocks:diorite"},
|
|
||||||
{ node="rocks:gabbro", min=-700},
|
|
||||||
}
|
|
||||||
for k,v in pairs(layers) do
|
|
||||||
v.ctx=minetest.get_content_id(v.node)
|
|
||||||
end
|
|
||||||
local layers_no=#layers
|
|
||||||
local n_layer= minetest.get_perlin_map(np_layer, pmapsize) : get2dMap_flat(pmapminpxz)
|
|
||||||
local n_intr= minetest.get_perlin_map(np_intr, pmapsize) : get2dMap_flat(pmapminpxz)
|
|
||||||
local nixz= 1
|
|
||||||
|
|
||||||
for z=minp.z, maxp.z do for x=minp.x, maxp.x do
|
|
||||||
-- loop
|
|
||||||
for y=minp.y, maxp.y do
|
|
||||||
local di=area:index(x,y,z)
|
|
||||||
local yn=y+n_layer[nixz]
|
|
||||||
local vintr=n_intr[nixz]
|
|
||||||
if vintr<1 then vintr=1 end
|
|
||||||
if data[di]==c_stone then
|
|
||||||
yn=yn*vintr -- vertical intrusion
|
|
||||||
for li=1, layers_no do
|
|
||||||
if yn > layers[li].min then
|
|
||||||
data[di]=layers[li].ctx
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
nixz= nixz+1
|
|
||||||
end end
|
|
||||||
|
|
||||||
vm:set_data(data)
|
|
||||||
--DEBUG: vm:set_lighting({day=15,night=2})
|
|
||||||
minetest.generate_ores(vm)
|
|
||||||
minetest.log("action", "rocks/layer/ "..math.ceil((os.clock() - t1) * 1000).." ms ")
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- ~ Tomas Brod
|
|
@ -1,49 +0,0 @@
|
|||||||
minetest.log("info","[rocks] mod initializing")
|
|
||||||
|
|
||||||
-- Load translation library if intllib is installed
|
|
||||||
|
|
||||||
if (minetest.get_modpath("intllib")) then
|
|
||||||
dofile(minetest.get_modpath("intllib").."/intllib.lua")
|
|
||||||
S = intllib.Getter(minetest.get_current_modname())
|
|
||||||
else
|
|
||||||
S = function ( s ) return s end
|
|
||||||
end
|
|
||||||
|
|
||||||
rocks={}
|
|
||||||
rocksl={}
|
|
||||||
|
|
||||||
rocksl.print=function(text)
|
|
||||||
minetest.log("info","/rocks "..text)
|
|
||||||
end
|
|
||||||
|
|
||||||
rocksl.seedprng=PseudoRandom(763)
|
|
||||||
rocksl.GetNextSeed=function()
|
|
||||||
return rocksl.seedprng:next()
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.clear_registered_ores()
|
|
||||||
|
|
||||||
local modpath=minetest.get_modpath(minetest.get_current_modname())
|
|
||||||
|
|
||||||
dofile(modpath.."/sed.lua")
|
|
||||||
dofile(modpath.."/ign.lua")
|
|
||||||
dofile(modpath.."/skarn.lua")
|
|
||||||
dofile(modpath.."/pegmatite.lua")
|
|
||||||
dofile(modpath.."/gensed.lua")
|
|
||||||
dofile(modpath.."/pipes.lua")
|
|
||||||
dofile(modpath.."/veins.lua")
|
|
||||||
|
|
||||||
minetest.register_on_generated(function(minp,maxp,seed)
|
|
||||||
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
|
||||||
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
|
||||||
local pr=PseudoRandom(seed)
|
|
||||||
rocksl.gensed(minp,maxp,seed,vm,area)
|
|
||||||
--rocksl.genign
|
|
||||||
rocksl.genvein(minp,maxp,pr,vm,area)
|
|
||||||
for _,pipe in pairs(rocks.pipes) do rocksl.genpipe(minp,maxp,pr,vm,area,pipe) end
|
|
||||||
vm:write_to_map(data)
|
|
||||||
end)
|
|
||||||
|
|
||||||
minetest.register_on_mapgen_init(function(mapgen_params)
|
|
||||||
-- todo: disable caves and ores
|
|
||||||
end)
|
|
61
rocks/layers.lua
Normal file
61
rocks/layers.lua
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
local np_elv = {
|
||||||
|
offset = -4, octaves = 2, persist = 0.4,
|
||||||
|
scale = 28,
|
||||||
|
spread = {x=25, y=25, z=25},
|
||||||
|
seed = -546,
|
||||||
|
}
|
||||||
|
local np_fault = {
|
||||||
|
offset = -5, octaves = 2, persist = 0.4,
|
||||||
|
scale = 10,
|
||||||
|
spread = {x=25, y=25, z=25},
|
||||||
|
seed = 632,
|
||||||
|
}
|
||||||
|
|
||||||
|
rocksl.genlayers = function (minp, maxp, seed, vm, area)
|
||||||
|
local t1 = os.clock()
|
||||||
|
local data = vm:get_data()
|
||||||
|
|
||||||
|
local chunksize = maxp.x - minp.x + 1
|
||||||
|
local pmapsize = {x = chunksize, y = chunksize, z = chunksize}
|
||||||
|
local minpxz = {x = minp.x, y = minp.z}
|
||||||
|
local c_stone= minetest.get_content_id("default:stone")
|
||||||
|
local c_sample=minetest.get_content_id("rocks:samplelayerblock")
|
||||||
|
local c_air=minetest.get_content_id("air")
|
||||||
|
|
||||||
|
n_elv= minetest.get_perlin_map(np_elv, pmapsize) : get2dMap_flat(minpxz)
|
||||||
|
n_fault= minetest.get_perlin_map(np_fault, pmapsize) : get2dMap_flat(minpxz)
|
||||||
|
|
||||||
|
local nixz=1
|
||||||
|
for z=minp.z, maxp.z do for x=minp.x, maxp.x do
|
||||||
|
|
||||||
|
local fault=n_fault[nixz]
|
||||||
|
local lmh=-10
|
||||||
|
if fault>0 then lmh=lmh+10 end
|
||||||
|
local lt=math.floor(n_elv[nixz])
|
||||||
|
if lt>0 then
|
||||||
|
if lt>18 then lt=18 end
|
||||||
|
local top=math.min(lmh,maxp.y)
|
||||||
|
local bot=math.max(1+lmh-lt,minp.y)
|
||||||
|
for y=bot, top do
|
||||||
|
local di=area:index(x,y,z)
|
||||||
|
data[di]=c_sample
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
nixz=nixz+1
|
||||||
|
if z%100>50 then
|
||||||
|
for y=minp.y, maxp.y do data[area:index(x,y,z)]=c_air end
|
||||||
|
end
|
||||||
|
|
||||||
|
end end
|
||||||
|
vm:set_data(data)
|
||||||
|
vm:set_lighting({day=15,night=15})
|
||||||
|
minetest.log("action", "rocks/genlayers/ "..math.ceil((os.clock() - t1) * 1000).." ms ")
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node( "rocks:samplelayerblock", {
|
||||||
|
description = S("Sample"),
|
||||||
|
tiles = { "rocks_Slate.png" },
|
||||||
|
is_ground_content = true, sounds = default.node_sound_stone_defaults(),
|
||||||
|
groups = {cracky=3},
|
||||||
|
})
|
@ -1,24 +0,0 @@
|
|||||||
--
|
|
||||||
-- Pegmatite vein
|
|
||||||
--
|
|
||||||
|
|
||||||
local CommonRarity=45
|
|
||||||
|
|
||||||
minetest.register_node( "rocks:pegmatite", {
|
|
||||||
description = S("Pegmatite"),
|
|
||||||
tiles = { "rocks_Pegmatite.png" },
|
|
||||||
groups = {cracky=3, stone=1},
|
|
||||||
is_ground_content = true, sounds = default.node_sound_stone_defaults(),
|
|
||||||
})
|
|
||||||
|
|
||||||
-- ores have to be redefined for pegmatite background
|
|
||||||
|
|
||||||
-- pegmatites are only 1 kind
|
|
||||||
rocks.register_vein("rocks:pegmatite",{
|
|
||||||
wherein={ "rocks:granite" },
|
|
||||||
miny=-160, maxy=20,
|
|
||||||
radius={ average=18, amplitude=0.3, frequency=16 },
|
|
||||||
density=80, rarity=CommonRarity,
|
|
||||||
ores={
|
|
||||||
}
|
|
||||||
})
|
|
@ -1,96 +0,0 @@
|
|||||||
-- experimental slow pipe generator
|
|
||||||
|
|
||||||
local function brush(data,area,pos,radius,content,ores,pr)
|
|
||||||
local rsq=radius^2
|
|
||||||
local orect
|
|
||||||
local oresc
|
|
||||||
radius=radius+2
|
|
||||||
for _,ore in pairs(ores) do
|
|
||||||
if pr:next(0,ore.scarcity)==0 then
|
|
||||||
orect=ore.c_ore
|
|
||||||
oresc=ore.density
|
|
||||||
end
|
|
||||||
end
|
|
||||||
for x=-radius, radius do
|
|
||||||
for y=-radius, radius do
|
|
||||||
for z=-radius, radius do
|
|
||||||
if (x^2)+(y^2)+(z^2)<=rsq then
|
|
||||||
local di=area:index(x+pos.x,y+pos.y,z+pos.z)
|
|
||||||
if oresc and (pr:next(0,oresc)==0) then
|
|
||||||
data[di]=orect
|
|
||||||
else
|
|
||||||
data[di]=content
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end end end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- the public table of registered pipes
|
|
||||||
rocks.pipes={}
|
|
||||||
local examplepipe={
|
|
||||||
bedrock={ "rocks:limestone" },
|
|
||||||
startrock={ "rocks:limestone" },
|
|
||||||
ymin=-200, ymax=-6,
|
|
||||||
scarcity=80,
|
|
||||||
radius=3,
|
|
||||||
content="default:wood",
|
|
||||||
scatter=
|
|
||||||
{
|
|
||||||
{ scarcity=7, density=4, ore="default:mese", cnt=0},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
table.insert(rocks.pipes,examplepipe)
|
|
||||||
--profiling
|
|
||||||
table.insert(rocks.pipes,{
|
|
||||||
bedrock={ "rocks:limestone" },
|
|
||||||
startrock={ "rocks:limestone" },
|
|
||||||
ymin=-200, ymax=-6,
|
|
||||||
scarcity=80,
|
|
||||||
radius=3,
|
|
||||||
content="default:dirt",
|
|
||||||
scatter=
|
|
||||||
{
|
|
||||||
{ scarcity=5, density=4, ore="default:mese", cnt=0},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
rocksl.genpipe=function(minp,maxp,pr,vm,area,descr)
|
|
||||||
local t1 = os.clock()
|
|
||||||
local data = vm:get_data()
|
|
||||||
|
|
||||||
local chunksizer = maxp.x - minp.x + 1
|
|
||||||
local chunksize = chunksizer + 1
|
|
||||||
local pmapsize = {x = chunksize, y = chunksize, z = chunksize}
|
|
||||||
local minpxz = {x = minp.x, y = minp.z}
|
|
||||||
|
|
||||||
local bedrocks={}
|
|
||||||
for _,node in pairs(descr.bedrock) do bedrocks[minetest.get_content_id(node)]=true end
|
|
||||||
local startrocks={}
|
|
||||||
for _,node in pairs(descr.startrock) do startrocks[minetest.get_content_id(node)]=true end
|
|
||||||
local content=minetest.get_content_id(descr.content)
|
|
||||||
for _,des in pairs(descr.scatter) do
|
|
||||||
des.c_ore=minetest.get_content_id(des.ore)
|
|
||||||
end
|
|
||||||
local orepr=PseudoRandom(pr:next())
|
|
||||||
|
|
||||||
local numpipes_raw=(chunksize/descr.scarcity)
|
|
||||||
local numpipes = math.floor(numpipes_raw + (pr:next(0,99)/100))
|
|
||||||
|
|
||||||
for vc=1, numpipes do
|
|
||||||
local pointA=vector.new(pr:next(0,chunksizer)+minp.x,pr:next(0,chunksizer)+minp.y,pr:next(0,chunksizer)+minp.z)
|
|
||||||
if (#startrocks>0)and(startrocks[data[area:indexp(pointA)]]==nil) then break end
|
|
||||||
local pointB=vector.new(pr:next(0,chunksizer)+minp.x,pr:next(0,chunksizer)+minp.y,pr:next(0,chunksizer)+minp.z)
|
|
||||||
local pointC=vector.new(pr:next(0,chunksizer)+minp.x,pr:next(0,chunksizer)+minp.y,pr:next(0,chunksizer)+minp.z)
|
|
||||||
local step=(1.8*descr.radius)/(vector.distance(pointA,pointB)+vector.distance(pointB,pointC))
|
|
||||||
for t=0, 1, step do
|
|
||||||
local p=vector.multiply(pointA,(1-t)^2)
|
|
||||||
p=vector.add(p, vector.multiply(pointB,2*t*(1-t)) )
|
|
||||||
p=vector.add(p, vector.multiply(pointC,t*t) )
|
|
||||||
p=vector.round(p)
|
|
||||||
brush(data,area,p,descr.radius,content,descr.scatter,orepr)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
vm:set_data(data)
|
|
||||||
minetest.log("action", "rocks/genpipe/ "..math.ceil((os.clock() - t1) * 1000).." ms ")
|
|
||||||
end
|
|
185
rocks/sed.lua
185
rocks/sed.lua
@ -1,185 +0,0 @@
|
|||||||
--
|
|
||||||
-- Sedimentary Layer
|
|
||||||
--
|
|
||||||
|
|
||||||
-- Mudstone Sed soft Ocean, beach, river, glaciers
|
|
||||||
minetest.register_node( "rocks:mudstone", {
|
|
||||||
description = S("Mudstone"),
|
|
||||||
tiles = { "rocks_Mudstone.png" },
|
|
||||||
groups = {cracky=1, crumbly=3},
|
|
||||||
is_ground_content = true, sounds = default.node_sound_dirt_defaults(),
|
|
||||||
})
|
|
||||||
-- more rock defs
|
|
||||||
minetest.register_node( "rocks:limestone", {
|
|
||||||
description = S("Limestone"),
|
|
||||||
tiles = { "rocks_Limestone.png" },
|
|
||||||
is_ground_content = true, sounds = default.node_sound_stone_defaults(),
|
|
||||||
groups = {cracky=2},
|
|
||||||
})
|
|
||||||
minetest.register_node( "rocks:laterite", {
|
|
||||||
description = S("Laterite clay"),
|
|
||||||
tiles = { "rocks_laterite.png" },
|
|
||||||
is_ground_content = true, sounds = default.node_sound_dirt_defaults(),
|
|
||||||
groups = {crumbly=3},
|
|
||||||
})
|
|
||||||
|
|
||||||
local beach_max=4
|
|
||||||
local lowland_max=27
|
|
||||||
local highland_max=200
|
|
||||||
local beach_min=-7
|
|
||||||
local lowland_min=5
|
|
||||||
local highland_min=28
|
|
||||||
|
|
||||||
do
|
|
||||||
-- Modify default grassland biome
|
|
||||||
local grassland=minetest.registered_biomes["default:grassland"] or
|
|
||||||
{ -- default biome, if no biome mod is installed
|
|
||||||
name = "rocks:grassland",
|
|
||||||
node_top = "air",
|
|
||||||
depth_top = 0,
|
|
||||||
depth_filler=0,
|
|
||||||
y_min = lowland_min,
|
|
||||||
y_max = lowland_max,
|
|
||||||
heat_point = 50,
|
|
||||||
humidity_point = 50,
|
|
||||||
}
|
|
||||||
local mountains={ -- default mountain biome
|
|
||||||
name = "rocks:mountain",
|
|
||||||
node_top = "default:dirt_with_grass",
|
|
||||||
depth_top = 1,
|
|
||||||
node_filler = "default:dirt",
|
|
||||||
depth_filler = 2,
|
|
||||||
node_stone = nil,
|
|
||||||
y_min = highland_min,
|
|
||||||
y_max = highland_max,
|
|
||||||
heat_point = 50,
|
|
||||||
humidity_point = 50,
|
|
||||||
}
|
|
||||||
-- The biome layers are: dust, top, filler, stone
|
|
||||||
-- On beach: dust, shore_top, shore_filler, underwater
|
|
||||||
-- coastside: dust, top, filler, shore_filler, underwater, stone
|
|
||||||
if #minetest.registered_biomes > 1 then
|
|
||||||
minetest.log("error","Biomes registered before [rocks] discarded, please depend the mod on 'rocks' to fix this.")
|
|
||||||
-- can't just re-register them here, cause clear_biomes also clears decorations
|
|
||||||
end
|
|
||||||
minetest.clear_registered_biomes()
|
|
||||||
-- hook to inject our sedimentary stone to new biomes
|
|
||||||
local old_register_biome=minetest.register_biome
|
|
||||||
minetest.register_biome=function(def)
|
|
||||||
--print("[rocks] register_biome .name="..def.name)
|
|
||||||
for n,v in pairs(def) do
|
|
||||||
--if type(v)~="table" then print(" "..n.."="..v) end
|
|
||||||
end
|
|
||||||
local cor=false -- was the biomeheight patched?
|
|
||||||
local tl=3 -- tolerance in determining biome type based on y_min/max values
|
|
||||||
local btype -- biome type (:string)
|
|
||||||
if (def.y_max>3000) and (def.y_min<=highland_min) then
|
|
||||||
-- correct upper boundary of registered bimes
|
|
||||||
if (def.y_min<10) and (def.y_min>0) then def.y_max=lowland_max cor=true end
|
|
||||||
if (def.y_min<30) and (def.y_min>10) then def.y_max=highland_max cor=true end
|
|
||||||
minetest.log("action","/rocks correcting upper bound on biome "..def.name.." to "..def.y_max)
|
|
||||||
end
|
|
||||||
-- actual detection code
|
|
||||||
if def.node_stone=="default:desert_stone" then btype="desert"
|
|
||||||
elseif (def.y_min>beach_min-tl) and (def.y_max<beach_max+tl) then btype="beach"
|
|
||||||
elseif (def.y_min>0) and (def.y_max<lowland_max+tl) then btype="lowland"
|
|
||||||
elseif (def.y_min>highland_min-tl) and (def.y_max<highland_max+tl) then btype="highland"
|
|
||||||
elseif (def.y_min<-3000) and (def.y_max<lowland_min+tl) then btype="ocean"
|
|
||||||
else minetest.log("error", "/rocks could not guess elevation type for biome "..def.name) end
|
|
||||||
rocksl.print("register_biome .name="..def.name.." -> btype="..btype)
|
|
||||||
-- patch the new biomes with our rocks
|
|
||||||
if btype=="lowland" then
|
|
||||||
--def.node_filler="rocks:mudstone"
|
|
||||||
--def.depth_filler=11
|
|
||||||
--def.node_stone="rocks:granite"
|
|
||||||
if (def.humidity_point>80) and (def.heat_point>80) then
|
|
||||||
--def.node_filler="rocks:laterite"
|
|
||||||
end
|
|
||||||
elseif btype=="highland" then
|
|
||||||
def.node_filler="rocks:limestone"
|
|
||||||
def.node_stone="rocks:limestone"
|
|
||||||
def.depth_filler=15
|
|
||||||
elseif btype=="beach" then
|
|
||||||
def.node_stone="rocks:granite"
|
|
||||||
def.y_min=beach_min
|
|
||||||
if def.heat_point<50 then
|
|
||||||
def.node_top="default:gravel"
|
|
||||||
def.node_filler="default:gravel"
|
|
||||||
def.depth_filler=2
|
|
||||||
elseif def.node_top=="default:sand" then
|
|
||||||
if def.depth_top<2 then def.depth_top=3 end
|
|
||||||
def.node_filler="default:sandstone"
|
|
||||||
def.depth_filler=5
|
|
||||||
end
|
|
||||||
elseif btype=="ocean" then
|
|
||||||
def.node_stone="rocks:basalt"
|
|
||||||
def.node_top="default:gravel"
|
|
||||||
def.node_filler="rocks:limestone"
|
|
||||||
end
|
|
||||||
do -- deactivate the added and removed shore-thing of MGv7
|
|
||||||
-- to fix weirid sand layers underground
|
|
||||||
def.node_shore_top=def.node_top
|
|
||||||
def.node_shore_filler=def.node_filler
|
|
||||||
def.node_underwater=def.node_top
|
|
||||||
end
|
|
||||||
-- and call the saved method to actually do the registration
|
|
||||||
old_register_biome(def)
|
|
||||||
end
|
|
||||||
--now register the default grassland
|
|
||||||
minetest.register_biome(grassland)
|
|
||||||
-- create a default mountain biome...
|
|
||||||
minetest.register_biome(mountains)
|
|
||||||
-- hook the clear callback (fix biomesdev)
|
|
||||||
local old_clear=minetest.clear_registered_biomes
|
|
||||||
minetest.clear_registered_biomes=function()
|
|
||||||
old_clear()
|
|
||||||
minetest.log("action","/rocks re-registering default mountain biome!")
|
|
||||||
minetest.register_biome(mountains)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- more biomes
|
|
||||||
-- todo: mountains, alps, volcanos
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local reg=function(name,param)
|
|
||||||
minetest.register_ore({
|
|
||||||
ore=name,
|
|
||||||
wherein= {
|
|
||||||
"rocks:mudstone",
|
|
||||||
},
|
|
||||||
ore_type = "scatter",
|
|
||||||
clust_scarcity = 8^3,
|
|
||||||
clust_size = 10,
|
|
||||||
clust_num_ores = 10^3,
|
|
||||||
y_min = -20,
|
|
||||||
y_max = 40,
|
|
||||||
noise_threshhold = param.treshold,
|
|
||||||
noise_params = {
|
|
||||||
offset=0, scale=1, octaves=1, persist=0.3,
|
|
||||||
spread={x=param.spread, y=param.height, z=param.spread},
|
|
||||||
seed=rocksl.GetNextSeed(),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
-- this does register a new sedimentary vein.
|
|
||||||
rocks.register_sedimentary=reg
|
|
||||||
|
|
||||||
-- follows the only thing remaining from old ver :)
|
|
||||||
|
|
||||||
-- Sedimentary rock hardness and distribution
|
|
||||||
-- Rock Hard Distribution
|
|
||||||
--Breccia Weak Localized continental, folded
|
|
||||||
-->Claystone Weak Localized continental, folded, oceanic
|
|
||||||
--Conglomerate Weak Localized continental, folded
|
|
||||||
-->Limestone Medium Localized continental, folded; primary oceanic, hills
|
|
||||||
-->Coal - Large beds, twice as common in swamps
|
|
||||||
--reg("rocks:limestone", { spread=64, height=32, treshold=0.35 })
|
|
||||||
--reg("rocks:breccia", { spread=64, height=32, treshold=0.6 })
|
|
||||||
--reg("rocks:conglomerate", { spread=64, height=32, treshold=0.6 })
|
|
||||||
--reg("default:stone_with_coal", { spread=64, height=14, treshold=0.58 })
|
|
||||||
--reg("default:clay",{ spread=48, height=14, treshold=0.55 })
|
|
||||||
|
|
||||||
-- ~ Tomas Brod
|
|
@ -1,30 +0,0 @@
|
|||||||
--
|
|
||||||
-- Skarn deposit
|
|
||||||
--
|
|
||||||
|
|
||||||
local CommonRarity=40 --too high... should be like 76
|
|
||||||
local CommonRadius=10
|
|
||||||
local CommonWherein={ "rocks:granite", "rocks:limestone" }
|
|
||||||
|
|
||||||
minetest.register_node( "rocks:skarn", {
|
|
||||||
description = S("Skarn"),
|
|
||||||
tiles = { "rocks_Skarn.png" },
|
|
||||||
groups = {cracky=3, stone=1},
|
|
||||||
is_ground_content = true, sounds = default.node_sound_stone_defaults(),
|
|
||||||
})
|
|
||||||
|
|
||||||
-- skarn deposit
|
|
||||||
rocks.register_vein("rocks:skarn",{
|
|
||||||
wherein=CommonWherein,
|
|
||||||
miny=-320, maxy=300,
|
|
||||||
radius={ average=CommonRadius, amplitude=0.16, frequency=8 },
|
|
||||||
density=80, rarity=CommonRarity,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Todo:
|
|
||||||
-- There is also a chance of isolated lapis crystals, Gold
|
|
||||||
-- Molybdenite with Cu
|
|
||||||
-- wollastonite with Fe
|
|
||||||
-- enrichments: scheelite and wollastonite
|
|
||||||
|
|
||||||
-- ~ Tomas Brod
|
|
@ -1,5 +1,12 @@
|
|||||||
-- experimental fast vein generator
|
-- experimental fast vein generator
|
||||||
|
|
||||||
|
rocks.veins={}
|
||||||
|
|
||||||
|
table.insert(rocks.veins,{
|
||||||
|
scarcity=80,
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
rocksl.genvein=function(minp,maxp,pr,vm,area)
|
rocksl.genvein=function(minp,maxp,pr,vm,area)
|
||||||
local t1 = os.clock()
|
local t1 = os.clock()
|
||||||
|
Reference in New Issue
Block a user