diff --git a/init.lua b/init.lua index 962577f..e0e7b74 100644 --- a/init.lua +++ b/init.lua @@ -13,15 +13,20 @@ rocks={} rocksl={} rocksl.print=function(text) - print("[rocks] "..text) + minetest.log("info","/rocks "..text) +end + +rocksl.seedseq=0 +rocksl.GetNextSeed=function() + rocksl.seedseq=rocksl.seedseq+20 + return rocksl.seedseq end local modpath=minetest.get_modpath(minetest.get_current_modname()) -dofile(modpath.."/mapgen.lua") dofile(modpath.."/sed.lua") -dofile(modpath.."/ign.lua") -dofile(modpath.."/skarn.lua") +--dofile(modpath.."/ign.lua") +--dofile(modpath.."/skarn.lua") minetest.register_on_mapgen_init(function(mapgen_params) -- todo: disable caves and ores diff --git a/mapgen.lua b/mapgen.lua deleted file mode 100644 index 5fb5473..0000000 --- a/mapgen.lua +++ /dev/null @@ -1,230 +0,0 @@ --- --- layer generator --- - -local print2=function(text) - minetest.log("info","rocks/gen/ "..text) -end - -rocksl.seedseq=0 -rocksl.GetNextSeed=function() - rocksl.seedseq=rocksl.seedseq+20 - print2("seed "..rocksl.seedseq) - return rocksl.seedseq -end - -local layers={} - -rocks.layer_initialize=function(layer) - layer.stats={ count=0, total=0, node={}, totalnodes=0 } - table.insert(layers,layer) -end - -rocksl.register_stratus=function(layer,name,param) - table.insert(layer.localized,{ - primary=name, - spread=(param.spread or 20), - height=(param.height or 15), - treshold=(param.treshold or 0.85), - secondary=param.secondary, - seed=(rocksl.GetNextSeed()), - }) - layer.stats.node[name]=0 -end - -local veins={} - -rocks.register_vein=function(name,param) - local d={ - primary=name, - wherein=param.wherein, - miny=param.miny, maxy=param.maxy, - radius={ average=param.radius.average, amplitude=param.radius.amplitude, frequency=param.radius.frequency }, - density=(param.density or 1), - rarity=param.rarity, - secondary=(param.ores or {}), - } - table.insert(veins,d) -end - --- TODO: rewrite above function to register normal minetest ore, with --- special params, so the below func is not necesary. The mt oregen runs in --- separate therad (emerge) and it does not block server. --- params: type=scatter scacrity=1 size=3 ores=27 : full chance of spawning, only limited by noise thr --- EDIT: Need to edit mg_ore.cpp and Add following ore_types: layer, blob, region. - -- layer=2Dheightmap style layer with specific thickness - -- blob= 3D noise deformed sphere - -- region= 3D noise / treshold ore placement. - -rocksl.layergen=function(layer, minp, maxp, seed) - if ( (layer.top.offset+layer.top.scale)>minp.y ) - and ( (layer.bot.offset-layer.bot.scale)bottom[noise2d_ix]) and (y loc.treshold) then - nodes[pos]=loc.ctx - layer.stats.node[loc.ndn]=layer.stats.node[loc.ndn]+1 - break - end - end - end - noise2d_ix=noise2d_ix+1 - noise3d_ix=noise3d_ix+1 - end - noise2d_ix=noise2d_ix-side_length - end - noise2d_ix=noise2d_ix+side_length - end - print2("after loop: "..(os.clock()-timebefore)) - manipulator:set_data(nodes) - --manipulator:calc_lighting() - --manipulator:update_liquids() - if layer.debugging then - manipulator:set_lighting({day=15,night=15}) - end - manipulator:write_to_map() - print2("after commit: "..(os.clock()-timebefore)) - layer.stats.count=layer.stats.count+1 - layer.stats.total=layer.stats.total+(os.clock()-timebefore) - layer.stats.side=side_length - end -end - -local ignore_wherein=nil - -rocksl.veingen=function(veins,minp,maxp,seed) - local side_length=(maxp.y-minp.y) - local random=PseudoRandom(seed-79) - local timebefore=os.clock(); - local manipulator, emin, emax = minetest.get_mapgen_object("voxelmanip") - local nodes = manipulator:get_data() - local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax} - local did_generate=nil - for _,vein in ipairs(veins) do - if (minp.yvein.maxy) then - local vr2=vein.radius.average^2 - local vrm=vein.radius.average+vein.radius.amplitude - local noise_map=minetest.get_perlin_map( - { - seed=-79, - scale=vein.radius.amplitude, - offset=0, octaves=1, persist=0.7, - spread={x=vein.radius.frequency, y=vein.radius.frequency, z=vein.radius.frequency} - },{x=(vrm*2)+1, y=(vrm*2)+1, z=(vrm*2)+1} - ) - local iterations_count= (vein.rarity*side_length)^3 - -- Resolve node names to id's - iterations_count=iterations_count+(random:next(0,100)/100) - 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 - --old:local wherein_ctx=minetest.get_content_id(vein.wherein) - 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 - local x0=minp.x+ random:next(0,side_length) - local y0=minp.y+ random:next(0,side_length) - local z0=minp.z+ random:next(0,side_length) - local noise=noise_map:get3dMap_flat({x=x0-vrm, y=y0-vrm, z=z0-vrm}) - local noise_ix=1 - local posi = area:index(x0, y0, z0) - if ignore_wherein or wherein_set[nodes[posi]] then - print("vein "..vein.primary.." @ "..x0..","..y0..","..z0.." vrm="..vrm) - did_generate=1 - for x=-vrm, vrm do - for y=-vrm, vrm do - for z=-vrm, vrm do - local posc = {x=x+x0,y=y+y0,z=z+z0} - posi = area:index(posc.x, posc.y, posc.z) - local nv=noise[noise_ix] - 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 - local luck=random:next(0,99) - for _,sec in pairs(vein.secondary) do - luck=luck-sec.percent - if luck<=0 then - nodes[posi]=sec.ctx - break - end - end - end - noise_ix=noise_ix+1 - end end end - else - --print("vein "..vein.primary.." bad environmnent -"..minetest.get_node({x0,y0,z0}).name.."="..nodes[posi]) - end - end - end - end - if did_generate then - manipulator:set_data(nodes) - --manipulator:calc_lighting() - manipulator:write_to_map() - print("end veingen "..(os.clock()-timebefore)) - else - --print("end veingen (nothin generated)") - end -end - -minetest.register_on_generated(function(minp, maxp, seed) - for _,layer in pairs(layers) do rocksl.layergen(layer,minp,maxp,seed) end - rocksl.veingen(veins,minp,maxp,seed) -end) - -minetest.register_on_shutdown(function() - for _,ign in pairs(layers) do - print("[rocks] Stats for layer "..ign.name) - if (ign.stats.count==0) then - print("[rocks] |- stats not available, no chunks generated") - else - print("[rocks] |- generated total "..ign.stats.count.." chunks in "..ign.stats.total.." seconds ("..(ign.stats.total/ign.stats.count).." seconds per "..ign.stats.side.."^3 chunk)") - for name,total in pairs(ign.stats.node) do - print("[rocks] |- "..name..": "..total.." nodes placed ("..(total*100)/(ign.stats.totalnodes).." %)") - end - end - end -end) - --- ~ Tomas Brod \ No newline at end of file diff --git a/sed.lua b/sed.lua index d65a6af..b20bc87 100644 --- a/sed.lua +++ b/sed.lua @@ -2,24 +2,6 @@ -- Sedimentary Layer -- -local sed={ - name="sed", - top={ - offset = 20, scale = 0, - spread = {x=80, y=80, z=80}, - octaves = 0, persist = 0 }, - bot={ - offset = -16, scale = 10, seed=rocksl.GetNextSeed(), - spread = {x=80, y=80, z=80}, - octaves = 2, persist = 0.7 }, - primary={ name="rocks:mudstone" }, - localized={}, - stats={ count=0, total=0, node={}, totalnodes=0 }, - debugging=nil -} - -rocks.layer_initialize(sed) - -- Mudstone Sed soft Ocean, beach, river, glaciers minetest.register_node( "rocks:mudstone", { description = S("Mudstone"), @@ -28,6 +10,26 @@ minetest.register_node( "rocks:mudstone", { is_ground_content = true, sounds = default.node_sound_dirt_defaults(), }) +do -- Modify default grassland biome + local grassland=minetest.registered_biomes["default:grassland"] or + { + name = "rocks:grassland", + node_top = "default:dirt_with_grass", + depth_top = 1, + y_min = 5, + y_max = 31000, + heat_point = 50, + humidity_point = 50, + } + grassland.node_filler="rocks:mudstone" + grassland.depth_filler=11 + minetest.clear_registered_biomes() + minetest.register_biome(grassland) +end + +-- more biomes + + -- more rock defs minetest.register_node( "rocks:limestone", { description = S("Limestone"), @@ -38,7 +40,24 @@ minetest.register_node( "rocks:limestone", { local reg=function(name,param) - rocksl.register_stratus(sed,name,param) + minetest.register_ore({ + ore=name, + wherein= { + "rocks:mudstone", + }, + ore_type = "scatter", + clust_scarcity = 1, + clust_size = 3, + clust_num_ores = 27, + y_min = -20, + y_max = 40, + noise_threshhold = param.treshold, + noise_params = { + offset=0, scale=1, octaves=3, persist=0.3, + spread={x=param.spread, y=param.height, z=param.spread}, + seed=rocksl.GetNextSeed(), + }, + }) end rocks.register_sedimentary=reg @@ -50,10 +69,10 @@ rocks.register_sedimentary=reg --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: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=48, height=14, treshold=0.50 }) - reg("default:clay",{ spread=48, height=14, treshold=0.50 }) + reg("default:stone_with_coal", { spread=64, height=14, treshold=0.60 }) + reg("default:clay",{ spread=48, height=14, treshold=0.56 }) -- ~ Tomas Brod \ No newline at end of file