New ore generator
|
@ -34,11 +34,13 @@ function string:capitalize()
|
|||
end
|
||||
|
||||
function string:remove_modname_prefix()
|
||||
local i = self:find(":")
|
||||
if i then
|
||||
return self:sub(i+1)
|
||||
for i = 1,2 do
|
||||
local i = self:find(":")
|
||||
if i then
|
||||
self = self:sub(i+1)
|
||||
end
|
||||
end
|
||||
return nil
|
||||
return self
|
||||
end
|
||||
|
||||
function string:get_modname_prefix()
|
||||
|
@ -50,13 +52,7 @@ function string:get_modname_prefix()
|
|||
if i then
|
||||
return self:sub(1, i-1)
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function set_node_instead_air(pos, node)
|
||||
if minetest.env:get_node(pos).name == "air" then
|
||||
minetest.env:set_node(pos, node)
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
function merge(lhs, rhs)
|
||||
|
|
|
@ -48,4 +48,41 @@ minetest.register_alias("default:cobble", "default:stone_small_rock")
|
|||
minetest.register_alias("default:cobbleblock", "default:stone_macadam")
|
||||
minetest.register_alias("default:cobbleblock_flat", "default:stone_bricks")
|
||||
minetest.register_alias("default:cobble_node", "default:stone_small_rock_node")
|
||||
minetest.register_alias("default:coal_lump", "minerals:charcoal")
|
||||
minetest.register_alias("default:coal_lump", "minerals:charcoal")
|
||||
minetest.register_alias("ores:lignite","ores:lignite_in_default_stone")
|
||||
minetest.register_alias("ores:anthracite","ores:anthracite_in_default_stone")
|
||||
minetest.register_alias("ores:bituminous_coal","ores:bituminous_coal_in_default_stone")
|
||||
minetest.register_alias("ores:magnetite","ores:magnetite_in_default_stone")
|
||||
minetest.register_alias("ores:hematite","ores:hematite_in_default_stone")
|
||||
minetest.register_alias("ores:limonite","ores:limonite_in_default_stone")
|
||||
minetest.register_alias("ores:bismuthinite","ores:bismuthinite_in_default_stone")
|
||||
minetest.register_alias("ores:cassiterite","ores:cassiterite_in_default_stone")
|
||||
minetest.register_alias("ores:galena","ores:galena_in_default_stone")
|
||||
minetest.register_alias("ores:garnierite","ores:garnierite_in_default_stone")
|
||||
minetest.register_alias("ores:malachite","ores:malachite_in_default_stone")
|
||||
minetest.register_alias("ores:native_copper","ores:native_copper_in_default_stone")
|
||||
minetest.register_alias("ores:native_copper_desert","ores:native_copper_in_default_desert_stone")
|
||||
minetest.register_alias("ores:native_gold","ores:native_gold_in_default_stone")
|
||||
minetest.register_alias("ores:native_gold_desert","ores:native_gold_in_default_desert_stone")
|
||||
minetest.register_alias("ores:native_silver","ores:native_silver_in_default_stone")
|
||||
minetest.register_alias("ores:native_platinum","ores:native_platinum_in_default_stone")
|
||||
minetest.register_alias("ores:sphalerite","ores:sphalerite_in_default_stone")
|
||||
minetest.register_alias("ores:tetrahedrite","ores:tetrahedrite_in_default_stone")
|
||||
minetest.register_alias("ores:lazurite","ores:lazurite_in_default_stone")
|
||||
minetest.register_alias("ores:bauxite","ores:bauxite_in_default_stone")
|
||||
minetest.register_alias("ores:cinnabar","ores:cinnabar_in_default_stone")
|
||||
minetest.register_alias("ores:cryolite","ores:cryolite_in_default_stone")
|
||||
minetest.register_alias("ores:graphite","ores:graphite_in_default_stone")
|
||||
minetest.register_alias("ores:gypsum","ores:gypsum_in_default_stone")
|
||||
minetest.register_alias("ores:jet","ores:jet_in_default_stone")
|
||||
minetest.register_alias("ores:kaolinite","ores:kaolinite_in_default_stone")
|
||||
minetest.register_alias("ores:kimberlite","ores:kimberlite_in_default_stone")
|
||||
minetest.register_alias("ores:olivine","ores:olivine_in_default_stone")
|
||||
minetest.register_alias("ores:petrified_wood","ores:petrified_wood_in_default_stone")
|
||||
minetest.register_alias("ores:saltpeter","ores:saltpeter_in_default_stone")
|
||||
minetest.register_alias("ores:satinspar","ores:satin_spar_in_default_stone")
|
||||
minetest.register_alias("minerals:satinspar", "minerals:satin_spar")
|
||||
minetest.register_alias("ores:selenite","ores:selenite_in_default_stone")
|
||||
minetest.register_alias("ores:serpentine","ores:serpentine_in_default_stone")
|
||||
minetest.register_alias("ores:sylvite","ores:sylvite_in_default_stone")
|
||||
minetest.register_alias("ores:tenorite","ores:tenorite_in_default_stone")
|
|
@ -21,8 +21,6 @@ MINERALS_LIST={
|
|||
---------------------------
|
||||
'cinnabar',
|
||||
'cryolite',
|
||||
'galena',
|
||||
'garnierite',
|
||||
'graphite',
|
||||
'gypsum',
|
||||
'jet',
|
||||
|
@ -32,7 +30,7 @@ MINERALS_LIST={
|
|||
'petrified_wood',
|
||||
'pitchblende',
|
||||
'saltpeter',
|
||||
'satinspar',
|
||||
'satin_spar',
|
||||
'selenite',
|
||||
'serpentine',
|
||||
'sulfur',
|
||||
|
@ -64,8 +62,6 @@ MINERALS_DESC_LIST={
|
|||
---------------------------
|
||||
'Cinnabar',
|
||||
'Cryolite',
|
||||
'Galena',
|
||||
'Garnierite',
|
||||
'Graphite',
|
||||
'Gypsum',
|
||||
'Jet',
|
||||
|
@ -75,7 +71,7 @@ MINERALS_DESC_LIST={
|
|||
'Petrified wood',
|
||||
'Pitchblende',
|
||||
'Saltpeter',
|
||||
'Satinspar',
|
||||
'Satin Spar',
|
||||
'Selenite',
|
||||
'Serpentine',
|
||||
'Sulfur',
|
||||
|
|
Before Width: | Height: | Size: 658 B After Width: | Height: | Size: 658 B |
|
@ -1,2 +1,3 @@
|
|||
minerals
|
||||
grounds
|
||||
default
|
|
@ -0,0 +1,174 @@
|
|||
local function generate_peat(name, wherein, minp, maxp, seed, chunks_per_volume, chunk_size, ore_per_chunk, height_min, height_max)
|
||||
if maxp.y < height_min or minp.y > height_max then
|
||||
return
|
||||
end
|
||||
local y_min = math.max(minp.y, height_min)
|
||||
local y_max = math.min(maxp.y, height_max)
|
||||
local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
|
||||
local pr = PseudoRandom(seed)
|
||||
local num_chunks = math.floor(chunks_per_volume * volume)
|
||||
local inverse_chance = math.floor(chunk_size*chunk_size*chunk_size / ore_per_chunk)
|
||||
--print("generate_ore num_chunks: "..dump(num_chunks))
|
||||
for i=1,num_chunks do
|
||||
local y0 = pr:next(y_min, y_max-chunk_size+1)
|
||||
if y0 >= height_min and y0 <= height_max then
|
||||
local x0 = pr:next(minp.x, maxp.x-chunk_size+1)
|
||||
local z0 = pr:next(minp.z, maxp.z-chunk_size+1)
|
||||
local p0 = {x=x0, y=y0, z=z0}
|
||||
for x1=0,chunk_size-1 do
|
||||
for y1=0,chunk_size-1 do
|
||||
for z1=0,chunk_size-1 do
|
||||
if pr:next(1,inverse_chance) == 1 then
|
||||
local x2 = x0+x1
|
||||
local y2 = y0+y1
|
||||
local z2 = z0+z1
|
||||
local p2 = {x=x2, y=y2, z=z2}
|
||||
if minetest.env:get_node(p2).name == wherein then
|
||||
if minetest.env:get_node({x=p2.x, y=p2.y + 1, z=p2.z}).name == "default:water_source" and
|
||||
minetest.env:get_node({x=p2.x, y=p2.y + 2, z=p2.z}).name == "air" then
|
||||
minetest.env:set_node(p2, {name=name})
|
||||
end
|
||||
if minetest.env:get_node({x=p2.x, y=p2.y + 1, z=p2.z}).name == "default:water_source" and
|
||||
minetest.env:get_node({x=p2.x, y=p2.y + 2, z=p2.z}).name == "default:water_source" and
|
||||
minetest.env:get_node({x=p2.x, y=p2.y + 3, z=p2.z}).name == "air" then
|
||||
minetest.env:set_node(p2, {name=name})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function is_node_beside(pos, node)
|
||||
local sides = {{x=-1,y=0,z=0}, {x=1,y=0,z=0}, {x=0,y=0,z=-1}, {x=0,y=0,z=1}, {x=0,y=-1,z=0}, {x=0,y=1,z=0},}
|
||||
for i, s in ipairs(sides) do
|
||||
if minetest.env:get_node({x=pos.x+s.x,y=pos.y+s.y,z=pos.z+s.z}).name == node then
|
||||
return true, minetest.dir_to_wallmounted(s)
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function generate_sulfur(name, minp, maxp, seed, chunks_per_volume, chunk_size, ore_per_chunk, height_min, height_max)
|
||||
if maxp.y < height_min or minp.y > height_max then
|
||||
return
|
||||
end
|
||||
local y_min = math.max(minp.y, height_min)
|
||||
local y_max = math.min(maxp.y, height_max)
|
||||
local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
|
||||
local pr = PseudoRandom(seed)
|
||||
local num_chunks = math.floor(chunks_per_volume * volume)
|
||||
local inverse_chance = math.floor(chunk_size*chunk_size*chunk_size / ore_per_chunk)
|
||||
for i=1,num_chunks do
|
||||
local y0 = pr:next(y_min, y_max-chunk_size+1)
|
||||
if y0 >= height_min and y0 <= height_max then
|
||||
local x0 = pr:next(minp.x, maxp.x-chunk_size+1)
|
||||
local z0 = pr:next(minp.z, maxp.z-chunk_size+1)
|
||||
local p0 = {x=x0, y=y0, z=z0}
|
||||
for x1=0,chunk_size-1 do
|
||||
for y1=0,chunk_size-1 do
|
||||
for z1=0,chunk_size-1 do
|
||||
if pr:next(1,inverse_chance) == 1 then
|
||||
local x2 = x0+x1
|
||||
local y2 = y0+y1
|
||||
local z2 = z0+z1
|
||||
local p2 = {x=x2, y=y2, z=z2}
|
||||
if minetest.env:get_node(p2).name == "air" and minetest.env:find_node_near(p2, 3, {"default:lava_source","default:lava_flowing"}) then
|
||||
local inb, side = is_node_beside(p2, "default:stone")
|
||||
if inb then
|
||||
minetest.env:set_node(p2, {name=name, param2 = side})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function generate_ore(name, wherein, minp, maxp, seed, chunks_per_volume, chunk_size,
|
||||
ore_per_chunk, height_min, height_max, noise_min, noise_max)
|
||||
if maxp.y < height_min or minp.y > height_max then
|
||||
return
|
||||
end
|
||||
local ore_noise1
|
||||
local ore_noise2
|
||||
local y_min = math.max(minp.y, height_min)
|
||||
local y_max = math.min(maxp.y, height_max)
|
||||
local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
|
||||
local pr = PseudoRandom(seed)
|
||||
local num_chunks = math.floor(chunks_per_volume * volume)
|
||||
local inverse_chance = math.floor(chunk_size*chunk_size*chunk_size / ore_per_chunk)
|
||||
|
||||
-- perlin. Only done if borders are defined.
|
||||
if type(noise_min) == "number" or type(noise_max) == "number" then
|
||||
if type(noise_min) ~= "number" then
|
||||
noise_min = -2
|
||||
end
|
||||
if type(noise_max) ~= "number" then
|
||||
noise_max = 2
|
||||
end
|
||||
ore_noise1 = minetest.env:get_perlin(seed, 3, 0.7, 100)
|
||||
end
|
||||
|
||||
--print("generate_ore num_chunks: "..dump(num_chunks))
|
||||
for i=1,num_chunks do
|
||||
local y0 = pr:next(y_min, y_max-chunk_size+1)
|
||||
if y0 >= height_min and y0 <= height_max then
|
||||
local x0 = pr:next(minp.x, maxp.x-chunk_size+1)
|
||||
local z0 = pr:next(minp.z, maxp.z-chunk_size+1)
|
||||
local p0 = {x=x0, y=y0, z=z0}
|
||||
|
||||
-- perlin
|
||||
if type(noise_min) == "number" or type(noise_max) == "number" then
|
||||
ore_noise2 = (ore_noise1:get3d(p0))
|
||||
end
|
||||
|
||||
for x1=0,chunk_size-1 do
|
||||
for y1=0,chunk_size-1 do
|
||||
for z1=0,chunk_size-1 do
|
||||
if pr:next(1,inverse_chance) == 1 then
|
||||
local x2 = x0+x1
|
||||
local y2 = y0+y1
|
||||
local z2 = z0+z1
|
||||
local p2 = {x=x2, y=y2, z=z2}
|
||||
if minetest.env:get_node(p2).name == wherein then
|
||||
|
||||
-- perlin
|
||||
if type(noise_min) == "number" or type(noise_max) == "number" then
|
||||
if ore_noise2 >= noise_min and ore_noise2 <= noise_max then
|
||||
minetest.env:set_node(p2, {name=name})
|
||||
end
|
||||
else
|
||||
minetest.env:set_node(p2, {name=name})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--print("generate_perlinore done")
|
||||
end
|
||||
|
||||
minetest.after(0, function()
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
local pr = PseudoRandom(seed)
|
||||
local ore = realtest.registered_ores[realtest.registered_ores_list[pr:next(1,#realtest.registered_ores_list)]]
|
||||
|
||||
for __, wherein in ipairs(ore.wherein) do
|
||||
generate_ore(ore.name.."_in_"..wherein:gsub(":","_"), wherein, minp, maxp, seed+ore.delta_seed,
|
||||
ore.chunks_per_volume, ore.chunk_size,
|
||||
ore.ore_per_chunk, ore.height_min, ore.height_max, ore.noise_min, ore.noise_max)
|
||||
end
|
||||
generate_sulfur("ores:sulfur", minp, maxp, seed+400, 1/8/8/8/8, 10, 850, -30912, 200)
|
||||
generate_peat("ores:peat", "default:dirt", minp, maxp, seed+401, 1/8/16/24, 10, 1000, -100, 200)
|
||||
end)
|
||||
end)
|
|
@ -1,433 +1,3 @@
|
|||
--
|
||||
-- Register nodes
|
||||
--
|
||||
|
||||
ores = {}
|
||||
|
||||
ores.list = {
|
||||
"lignite",
|
||||
"anthracite",
|
||||
"bituminous_coal",
|
||||
"magnetite",
|
||||
"hematite",
|
||||
"limonite",
|
||||
"bismuthinite",
|
||||
"cassiterite",
|
||||
"galena",
|
||||
"garnierite",
|
||||
"malachite",
|
||||
"native_copper",
|
||||
"native_gold",
|
||||
"native_silver",
|
||||
"sphalerite",
|
||||
"tetrahedrite",
|
||||
"lazurite",
|
||||
"bauxite",
|
||||
---------------------------
|
||||
'cinnabar',
|
||||
'cryolite',
|
||||
'galena',
|
||||
'garnierite',
|
||||
'graphite',
|
||||
'gypsum',
|
||||
'jet',
|
||||
'kaolinite',
|
||||
'kimberlite',
|
||||
'olivine',
|
||||
'petrified_wood',
|
||||
-- 'pitchblende',
|
||||
'saltpeter',
|
||||
'satinspar',
|
||||
'selenite',
|
||||
'serpentine',
|
||||
'sylvite',
|
||||
'tenorite',
|
||||
}
|
||||
ores.desc_list = {
|
||||
"Lignite",
|
||||
"Anthracite",
|
||||
"Bituminous Coal",
|
||||
"Magnetite",
|
||||
"Hematite",
|
||||
"Limonite",
|
||||
"Bismuthinite",
|
||||
"Cassiterite",
|
||||
"Galena",
|
||||
"Garnierite",
|
||||
"Malachite",
|
||||
"Native Copper",
|
||||
"Native Gold",
|
||||
"Native Silver",
|
||||
"Sphalerite",
|
||||
"Tetrahedrite",
|
||||
"Lapis",
|
||||
"Bauxite",
|
||||
---------------------------
|
||||
'Cinnabar',
|
||||
'Cryolite',
|
||||
'Galena',
|
||||
'Garnierite',
|
||||
'Graphite',
|
||||
'Gypsum',
|
||||
'Jet',
|
||||
'Kaolinite',
|
||||
'Kimberlite',
|
||||
'Olovine',
|
||||
'Petrified wood',
|
||||
-- 'Pitchblende',
|
||||
'Saltpeter',
|
||||
'Satinspar',
|
||||
'Selenite',
|
||||
'Serpentine',
|
||||
'Sylvite',
|
||||
'Tenorite',
|
||||
}
|
||||
|
||||
for i,ore in ipairs(ores.list) do
|
||||
minetest.register_node("ores:"..ore, {
|
||||
description = ores.desc_list[i],
|
||||
tile_images = {"default_stone.png^ores_"..ore..".png"},
|
||||
particle_image = {"minerals_"..ore..".png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3,drop_on_dig=1},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
{
|
||||
items = {"minerals:"..ore.." 2"},
|
||||
rarity = 15,
|
||||
},
|
||||
{
|
||||
items = {"minerals:"..ore},
|
||||
}
|
||||
}
|
||||
},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_node("ores:native_copper_desert", {
|
||||
description = "Native copper ore",
|
||||
tile_images = {"default_desert_stone.png^ores_native_copper.png"},
|
||||
particle_image = {"minerals_native_copper.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3,drop_on_dig=1},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
{
|
||||
items = {"minerals:native_copper 2"},
|
||||
rarity = 15,
|
||||
},
|
||||
{
|
||||
items = {"minerals:native_copper"},
|
||||
}
|
||||
}
|
||||
},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("ores:native_gold_desert", {
|
||||
description = "Native gold ore",
|
||||
tile_images = {"default_desert_stone.png^ores_native_gold.png"},
|
||||
particle_image = {"minerals_native_gold.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3,drop_on_dig=1},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
{
|
||||
items = {"minerals:native_gold 2"},
|
||||
rarity = 15,
|
||||
},
|
||||
{
|
||||
items = {"minerals:native_gold"},
|
||||
}
|
||||
}
|
||||
},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("ores:sulfur", {
|
||||
description = "Sulfur ore",
|
||||
drawtype = "signlike",
|
||||
tile_images = {"ores_sulfur.png"},
|
||||
particle_image = {"minerals_sulfur.png"},
|
||||
is_ground_content = true,
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
walkable = false,
|
||||
selection_box = {
|
||||
type = "wallmounted",
|
||||
},
|
||||
groups = {cracky=3,drop_on_dig=1,dig_immediate=2},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
{
|
||||
items = {"minerals:sulfur 3"},
|
||||
rarity = 15,
|
||||
},
|
||||
{
|
||||
items = {"minerals:sulfur 2"},
|
||||
}
|
||||
}
|
||||
},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("ores:peat", {
|
||||
description = "Peat",
|
||||
tile_images = {"ores_peat.png"},
|
||||
particle_image = {"ores_peat.png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=3,drop_on_dig=1,falling_node=1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
||||
--
|
||||
-- Generation ores
|
||||
--
|
||||
|
||||
local function generate_ore(name, wherein, minp, maxp, seed, chunks_per_volume, chunk_size, ore_per_chunk, height_min, height_max)
|
||||
if maxp.y < height_min or minp.y > height_max then
|
||||
return
|
||||
end
|
||||
local y_min = math.max(minp.y, height_min)
|
||||
local y_max = math.min(maxp.y, height_max)
|
||||
local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
|
||||
local pr = PseudoRandom(seed)
|
||||
local num_chunks = math.floor(chunks_per_volume * volume)
|
||||
local inverse_chance = math.floor(chunk_size*chunk_size*chunk_size / ore_per_chunk)
|
||||
for i=1,num_chunks do
|
||||
local y0 = pr:next(y_min, y_max-chunk_size+1)
|
||||
if y0 >= height_min and y0 <= height_max then
|
||||
local x0 = pr:next(minp.x, maxp.x-chunk_size+1)
|
||||
local z0 = pr:next(minp.z, maxp.z-chunk_size+1)
|
||||
local p0 = {x=x0, y=y0, z=z0}
|
||||
for x1=0,chunk_size-1 do
|
||||
for y1=0,chunk_size-1 do
|
||||
for z1=0,chunk_size-1 do
|
||||
if pr:next(1,inverse_chance) == 1 then
|
||||
local x2 = x0+x1
|
||||
local y2 = y0+y1
|
||||
local z2 = z0+z1
|
||||
local p2 = {x=x2, y=y2, z=z2}
|
||||
if minetest.env:get_node(p2).name == wherein then
|
||||
minetest.env:set_node(p2, {name=name})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function is_node_beside(pos, node)
|
||||
local sides = {{x=-1,y=0,z=0}, {x=1,y=0,z=0}, {x=0,y=0,z=-1}, {x=0,y=0,z=1}, {x=0,y=-1,z=0}, {x=0,y=1,z=0},}
|
||||
for i, s in ipairs(sides) do
|
||||
if minetest.env:get_node({x=pos.x+s.x,y=pos.y+s.y,z=pos.z+s.z}).name == node then
|
||||
return true, minetest.dir_to_wallmounted(s)
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function generate_sulfur(name, minp, maxp, seed, chunks_per_volume, chunk_size, ore_per_chunk, height_min, height_max)
|
||||
if maxp.y < height_min or minp.y > height_max then
|
||||
return
|
||||
end
|
||||
local y_min = math.max(minp.y, height_min)
|
||||
local y_max = math.min(maxp.y, height_max)
|
||||
local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
|
||||
local pr = PseudoRandom(seed)
|
||||
local num_chunks = math.floor(chunks_per_volume * volume)
|
||||
local inverse_chance = math.floor(chunk_size*chunk_size*chunk_size / ore_per_chunk)
|
||||
for i=1,num_chunks do
|
||||
local y0 = pr:next(y_min, y_max-chunk_size+1)
|
||||
if y0 >= height_min and y0 <= height_max then
|
||||
local x0 = pr:next(minp.x, maxp.x-chunk_size+1)
|
||||
local z0 = pr:next(minp.z, maxp.z-chunk_size+1)
|
||||
local p0 = {x=x0, y=y0, z=z0}
|
||||
for x1=0,chunk_size-1 do
|
||||
for y1=0,chunk_size-1 do
|
||||
for z1=0,chunk_size-1 do
|
||||
if pr:next(1,inverse_chance) == 1 then
|
||||
local x2 = x0+x1
|
||||
local y2 = y0+y1
|
||||
local z2 = z0+z1
|
||||
local p2 = {x=x2, y=y2, z=z2}
|
||||
if minetest.env:get_node(p2).name == "air" and minetest.env:find_node_near(p2, 3, {"default:lava_source","default:lava_flowing"}) then
|
||||
local inb, side = is_node_beside(p2, "default:stone")
|
||||
if inb then
|
||||
minetest.env:set_node(p2, {name=name, param2 = side})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function generate_peat(name, wherein, minp, maxp, seed, chunks_per_volume, chunk_size, ore_per_chunk, height_min, height_max)
|
||||
if maxp.y < height_min or minp.y > height_max then
|
||||
return
|
||||
end
|
||||
local y_min = math.max(minp.y, height_min)
|
||||
local y_max = math.min(maxp.y, height_max)
|
||||
local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
|
||||
local pr = PseudoRandom(seed)
|
||||
local num_chunks = math.floor(chunks_per_volume * volume)
|
||||
local inverse_chance = math.floor(chunk_size*chunk_size*chunk_size / ore_per_chunk)
|
||||
--print("generate_ore num_chunks: "..dump(num_chunks))
|
||||
for i=1,num_chunks do
|
||||
local y0 = pr:next(y_min, y_max-chunk_size+1)
|
||||
if y0 >= height_min and y0 <= height_max then
|
||||
local x0 = pr:next(minp.x, maxp.x-chunk_size+1)
|
||||
local z0 = pr:next(minp.z, maxp.z-chunk_size+1)
|
||||
local p0 = {x=x0, y=y0, z=z0}
|
||||
for x1=0,chunk_size-1 do
|
||||
for y1=0,chunk_size-1 do
|
||||
for z1=0,chunk_size-1 do
|
||||
if pr:next(1,inverse_chance) == 1 then
|
||||
local x2 = x0+x1
|
||||
local y2 = y0+y1
|
||||
local z2 = z0+z1
|
||||
local p2 = {x=x2, y=y2, z=z2}
|
||||
if minetest.env:get_node(p2).name == wherein then
|
||||
if minetest.env:get_node({x=p2.x, y=p2.y + 1, z=p2.z}).name == "default:water_source" and
|
||||
minetest.env:get_node({x=p2.x, y=p2.y + 2, z=p2.z}).name == "air" then
|
||||
minetest.env:set_node(p2, {name=name})
|
||||
end
|
||||
if minetest.env:get_node({x=p2.x, y=p2.y + 1, z=p2.z}).name == "default:water_source" and
|
||||
minetest.env:get_node({x=p2.x, y=p2.y + 2, z=p2.z}).name == "default:water_source" and
|
||||
minetest.env:get_node({x=p2.x, y=p2.y + 3, z=p2.z}).name == "air" then
|
||||
minetest.env:set_node(p2, {name=name})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
local pr = PseudoRandom(seed)
|
||||
local gen_ores = {
|
||||
{"ores:lignite", -3000, -500},
|
||||
{"ores:bituminous_coal", -6000, -3000},
|
||||
{"ores:anthracite", -8000, -6000},
|
||||
{"ores:bismuthinite"},
|
||||
{"ores:magnetite"},
|
||||
{"ores:hematite"},
|
||||
{"ores:limonite"},
|
||||
{"ores:cassiterite"},
|
||||
{"ores:galena"},
|
||||
{"ores:garnierite"},
|
||||
{"ores:malachite"},
|
||||
{"ores:native_copper"},
|
||||
{"ores:native_gold"},
|
||||
{"ores:native_silver"},
|
||||
{"ores:sphalerite"},
|
||||
{"ores:tetrahedrite"},
|
||||
{"ores:bauxite"},
|
||||
{"ores:lapis"},
|
||||
{'ores:cinnabar'},
|
||||
{'ores:cryolite'},
|
||||
{'ores:galena'},
|
||||
{'ores:garnierite'},
|
||||
{'ores:graphite', -31000, -8000},
|
||||
{'ores:gypsum'},
|
||||
{'ores:jet'},
|
||||
{'ores:kaolinite'},
|
||||
{'ores:kimberlite'},
|
||||
{'ores:olovine'},
|
||||
{'ores:petrified_wood'},
|
||||
-- {'ores:pitchblende'},
|
||||
{'ores:saltpeter'},
|
||||
{'ores:satinspar'},
|
||||
{'ores:selenite'},
|
||||
{'ores:serpentine'},
|
||||
{'ores:sylvite'},
|
||||
{'ores:tenorite'},
|
||||
}
|
||||
for i, ore in ipairs(gen_ores) do
|
||||
if pr:next(1,2) == 1 then
|
||||
generate_ore(ore[1], "default:stone", minp, maxp, seed+i, 1/8/8/8/8/8/8, 10, 850, ore[2] or -31000, ore[3] or 200)
|
||||
end
|
||||
end
|
||||
generate_sulfur("ores:sulfur", minp, maxp, seed, 1/8/8/8/8, 10, 850, -31000, 200)
|
||||
generate_peat("ores:peat", "default:dirt", minp, maxp, seed+19, 1/8/16/24, 10, 1000, -100, 200)
|
||||
generate_ore("ores:native_copper_desert", "default:desert_stone", minp, maxp, seed+20, 1/8/8/8/8/8/8, 6, 200, -31000, 200)
|
||||
generate_ore("ores:native_gold_desert", "default:desert_stone", minp, maxp, seed+21, 1/8/8/8/8/8/8, 5, 100, -31000, 200)
|
||||
generate_ore("ores:platinum", "ores:magnetite", minp, maxp, seed+22, 1/8/8/8/8/8/8, 10, 850, -31000, 200)
|
||||
|
||||
if pr:next(1,2) == 1 then
|
||||
-- Generate clay
|
||||
-- Assume X and Z lengths are equal
|
||||
local divlen = 10
|
||||
local divs = (maxp.x-minp.x)/divlen+1;
|
||||
for divx=0+1,divs-1-1 do
|
||||
for divz=0+1,divs-1-1 do
|
||||
local cx = minp.x + math.floor((divx+0.5)*divlen)
|
||||
local cz = minp.z + math.floor((divz+0.5)*divlen)
|
||||
if minetest.env:get_node({x=cx,y=1,z=cz}).name == "default:water_source" then
|
||||
local is_shallow = true
|
||||
local num_water_around = 0
|
||||
if minetest.env:get_node({x=cx-divlen*2,y=1,z=cz+0}).name == "default:water_source" then
|
||||
num_water_around = num_water_around + 1 end
|
||||
if minetest.env:get_node({x=cx+divlen*2,y=1,z=cz+0}).name == "default:water_source" then
|
||||
num_water_around = num_water_around + 1 end
|
||||
if minetest.env:get_node({x=cx+0,y=1,z=cz-divlen*2}).name == "default:water_source" then
|
||||
num_water_around = num_water_around + 1 end
|
||||
if minetest.env:get_node({x=cx+0,y=1,z=cz+divlen*2}).name == "default:water_source" then
|
||||
num_water_around = num_water_around + 1 end
|
||||
if num_water_around >= 2 then
|
||||
is_shallow = false
|
||||
end
|
||||
if is_shallow then
|
||||
local y = pr:next(0,2)
|
||||
for y1=y,pr:next(y,y+1) do
|
||||
for x1=-divlen,divlen do
|
||||
for z1=-divlen,divlen do
|
||||
if minetest.env:get_node({x=cx+x1,y=y1,z=cz+z1}).name == "default:sand" and
|
||||
minetest.env:get_node({x=cx+x1,y=y1+1,z=cz+z1}).name == "default:water_source" then
|
||||
minetest.env:set_node({x=cx+x1,y=y1,z=cz+z1}, {name="default:sand_with_clay"})
|
||||
elseif minetest.env:get_node({x=cx+x1,y=y1,z=cz+z1}).name == "default:dirt" then
|
||||
minetest.env:set_node({x=cx+x1,y=y1,z=cz+z1}, {name="default:dirt_with_clay"})
|
||||
elseif minetest.env:get_node({x=cx+x1,y=y1,z=cz+z1}).name == "default:dirt_with_grass" then
|
||||
minetest.env:set_node({x=cx+x1,y=y1,z=cz+z1}, {name="default:dirt_with_grass_and_clay"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end)
|
||||
|
||||
--
|
||||
-- Recipes of crafting
|
||||
--
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "default:torch 2",
|
||||
recipe = "group:stick",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "ores:peat",
|
||||
burntime = 15,
|
||||
})
|
||||
dofile(minetest.get_modpath("ores").."/registration.lua")
|
||||
dofile(minetest.get_modpath("ores").."/generation.lua")
|
|
@ -0,0 +1,211 @@
|
|||
realtest.registered_ores = {}
|
||||
realtest.registered_ores_list = {}
|
||||
local d_seed = 0
|
||||
function realtest.register_ore(name, OreDef)
|
||||
local ore = {
|
||||
name = name,
|
||||
description = OreDef.description or "Ore",
|
||||
mineral = OreDef.mineral or "minerals:"..name:remove_modname_prefix(),
|
||||
wherein = OreDef.wherein or {"default:stone"},
|
||||
chunks_per_volume = OreDef.chunks_per_volume or 1/3/3/3/2,
|
||||
chunk_size = OreDef.chunk_size or 3,
|
||||
ore_per_chunk = OreDef.ore_per_chunk or 10,
|
||||
height_min = OreDef.height_min or -30912,
|
||||
height_max = OreDef.height_max or 30912,
|
||||
noise_min = OreDef.noise_min or 0.6,
|
||||
noise_max = OreDef.noise_max or nil,
|
||||
generate = true,
|
||||
delta_seed = OreDef.delta_seed or d_seed
|
||||
}
|
||||
d_seed = d_seed + 1
|
||||
if OreDef.generate == false then
|
||||
ore.generate = false
|
||||
end
|
||||
ore.particle_image = OreDef.particle_image or ore.mineral:gsub(":","_")..".png"
|
||||
realtest.registered_ores[name] = ore
|
||||
table.insert(realtest.registered_ores_list, name)
|
||||
local name_ = name:gsub(":","_")
|
||||
for i, wherein in ipairs(ore.wherein) do
|
||||
local wherein_ = wherein:gsub(":","_")
|
||||
local wherein_textures = {}
|
||||
if minetest.registered_nodes[wherein].tiles or minetest.registered_nodes[wherein].tile_images then
|
||||
for _, texture in ipairs(minetest.registered_nodes[wherein].tiles) do
|
||||
table.insert(wherein_textures, texture.."^"..name_..".png")
|
||||
end
|
||||
else
|
||||
wherein_textures = {name_..".png"}
|
||||
end
|
||||
minetest.register_node(":"..name.."_in_"..wherein_, {
|
||||
description = ore.description .. " Ore",
|
||||
tiles = wherein_textures,
|
||||
particle_image = {ore.particle_image},
|
||||
groups = {cracky=3,drop_on_dig=1,ore=1},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
{
|
||||
items = {ore.mineral.." 2"},
|
||||
rarity = 2
|
||||
},
|
||||
{
|
||||
items = {ore.mineral}
|
||||
}
|
||||
}
|
||||
},
|
||||
sounds = default.node_sound_stone_defaults()
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
ores.list = {
|
||||
-- "lignite",
|
||||
-- "anthracite",
|
||||
-- "bituminous_coal",
|
||||
"magnetite",
|
||||
"hematite",
|
||||
"limonite",
|
||||
"bismuthinite",
|
||||
"cassiterite",
|
||||
"galena",
|
||||
"garnierite",
|
||||
"malachite",
|
||||
-- "native_copper",
|
||||
-- "native_gold",
|
||||
"native_silver",
|
||||
"native_platinum",
|
||||
"sphalerite",
|
||||
"tetrahedrite",
|
||||
"lazurite",
|
||||
"bauxite",
|
||||
"cinnabar",
|
||||
"cryolite",
|
||||
-- "graphite",
|
||||
"gypsum",
|
||||
"jet",
|
||||
"kaolinite",
|
||||
"kimberlite",
|
||||
"olivine",
|
||||
"petrified_wood",
|
||||
-- "pitchblende",
|
||||
"saltpeter",
|
||||
"satin_spar",
|
||||
"selenite",
|
||||
"serpentine",
|
||||
"sylvite",
|
||||
"tenorite",
|
||||
}
|
||||
ores.desc_list = {
|
||||
-- "Lignite",
|
||||
-- "Anthracite",
|
||||
-- "Bituminous Coal",
|
||||
"Magnetite",
|
||||
"Hematite",
|
||||
"Limonite",
|
||||
"Bismuthinite",
|
||||
"Cassiterite",
|
||||
"Galena",
|
||||
"Garnierite",
|
||||
"Malachite",
|
||||
-- "Native Copper",
|
||||
-- "Native Gold",
|
||||
"Native Silver",
|
||||
"Native Platinum",
|
||||
"Sphalerite",
|
||||
"Tetrahedrite",
|
||||
"Lazurite",
|
||||
"Bauxite",
|
||||
'Cinnabar',
|
||||
'Cryolite',
|
||||
-- 'Graphite',
|
||||
'Gypsum',
|
||||
'Jet',
|
||||
'Kaolinite',
|
||||
'Kimberlite',
|
||||
'Olovine',
|
||||
'Petrified wood',
|
||||
-- 'Pitchblende',
|
||||
'Saltpeter',
|
||||
'Satin Spar',
|
||||
'Selenite',
|
||||
'Serpentine',
|
||||
'Sylvite',
|
||||
'Tenorite',
|
||||
}
|
||||
|
||||
for _, ore in ipairs(ores.list) do
|
||||
realtest.register_ore("ores:"..ore, {description = ores.desc_list[_]})
|
||||
end
|
||||
|
||||
realtest.register_ore("ores:native_copper", {
|
||||
description = "Native Copper",
|
||||
wherein = {"default:stone", "default:desert_stone"}
|
||||
})
|
||||
|
||||
realtest.register_ore("ores:native_gold", {
|
||||
description = "Native Gold",
|
||||
wherein = {"default:stone", "default:desert_stone"}
|
||||
})
|
||||
|
||||
realtest.register_ore("ores:lignite", {
|
||||
description = "Lignite",
|
||||
height_max = -500,
|
||||
height_min = -3000,
|
||||
ore_per_chunk = 15,
|
||||
chunks_per_volume = 1/3/3/3,
|
||||
})
|
||||
|
||||
realtest.register_ore("ores:bituminous_coal", {
|
||||
description = "Bituminous Coal",
|
||||
height_max = -3000,
|
||||
height_min = -6000,
|
||||
ore_per_chunk = 15,
|
||||
chunks_per_volume = 1/3/3/3,
|
||||
})
|
||||
|
||||
realtest.register_ore("ores:anthracite", {
|
||||
description = "Anthracite",
|
||||
height_max = -6000,
|
||||
height_min = -8000,
|
||||
ore_per_chunk = 15,
|
||||
chunks_per_volume = 1/3/3/3,
|
||||
})
|
||||
|
||||
realtest.register_ore("ores:graphite", {
|
||||
description = "Graphite",
|
||||
height_max = -8000,
|
||||
ore_per_chunk = 15,
|
||||
})
|
||||
|
||||
minetest.register_node("ores:sulfur", {
|
||||
description = "Sulfur Ore",
|
||||
drawtype = "signlike",
|
||||
tile_images = {"ores_sulfur.png"},
|
||||
particle_image = {"minerals_sulfur.png"},
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
walkable = false,
|
||||
selection_box = {
|
||||
type = "wallmounted",
|
||||
},
|
||||
groups = {cracky=3,drop_on_dig=1,dig_immediate=2},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
{
|
||||
items = {"minerals:sulfur 3"},
|
||||
rarity = 15,
|
||||
},
|
||||
{
|
||||
items = {"minerals:sulfur 2"},
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_node("ores:peat", {
|
||||
description = "Peat",
|
||||
tile_images = {"ores_peat.png"},
|
||||
particle_image = {"ores_peat.png"},
|
||||
groups = {crumbly=3,drop_on_dig=1,falling_node=1},
|
||||
sounds = default.node_sound_dirt_defaults(),
|
||||
})
|
Before Width: | Height: | Size: 602 B After Width: | Height: | Size: 590 B |
Before Width: | Height: | Size: 844 B After Width: | Height: | Size: 844 B |
Before Width: | Height: | Size: 951 B After Width: | Height: | Size: 951 B |