realtest_mt5/mods/ores/registration.lua

226 lines
5.8 KiB
Lua
Raw Normal View History

2020-03-30 22:41:58 +02:00
realtest.registered_ores = {}
realtest.registered_ores_list = {}
local d_seed = 0
local function copytable(t)
2020-03-30 22:57:09 +02:00
local t2 = {}
2020-03-30 22:41:58 +02:00
for k,i in pairs(t) do
t2[k] = i
end
return t2
end
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"},
clust_scarcity = 1/(OreDef.chunks_per_volume or 1/3/3/3/2),
clust_size = OreDef.chunk_size or 3,
clust_num_ores = OreDef.ore_per_chunk or 10,
2020-03-30 22:57:09 +02:00
y_min = OreDef.y_min or -30912,
y_max = OreDef.y_max or 30912,
noise_threshold = OreDef.noise_min or 1.2,
2020-03-30 22:41:58 +02:00
noise_params = {offset=0, scale=1, spread={x=100, y=100, z=100}, octaves=3, persist=0.70, seed = OreDef.delta_seed or d_seed},
generate = true
}
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 = {}
2020-03-30 22:46:01 +02:00
if minetest.registered_nodes[wherein].tiles or minetest.registered_nodes[wherein].tiles then
2020-03-30 22:41:58 +02:00
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,dropping_like_stone=1},
drop = {
max_items = 1,
items = {
{
items = {ore.mineral.." 2"},
rarity = 2
},
{
items = {ore.mineral}
}
}
},
sounds = default.node_sound_stone_defaults()
})
if ore.generate then
local oredef = copytable(ore)
oredef.ore = name.."_in_"..wherein_
oredef.ore_type = "scatter"
oredef.wherein = wherein
minetest.register_ore(oredef)
end
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',
'Olivine',
'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",
2020-03-30 22:57:09 +02:00
y_max = -500,
y_min = -3000,
2020-03-30 22:41:58 +02:00
ore_per_chunk = 15,
chunks_per_volume = 1/3/3/3,
})
realtest.register_ore("ores:bituminous_coal", {
description = "Bituminous Coal",
2020-03-30 22:57:09 +02:00
y_max = -3000,
y_min = -6000,
2020-03-30 22:41:58 +02:00
ore_per_chunk = 15,
chunks_per_volume = 1/3/3/3,
})
realtest.register_ore("ores:anthracite", {
description = "Anthracite",
2020-03-30 22:57:09 +02:00
y_max = -6000,
y_min = -8000,
2020-03-30 22:41:58 +02:00
ore_per_chunk = 15,
chunks_per_volume = 1/3/3/3,
})
realtest.register_ore("ores:graphite", {
description = "Graphite",
2020-03-30 22:57:09 +02:00
y_max = -8000,
2020-03-30 22:41:58 +02:00
ore_per_chunk = 15,
})
minetest.register_node("ores:sulfur", {
description = "Sulfur Ore",
2020-03-30 22:46:01 +02:00
tiles = {"default_stone.png^ores_sulfur.png"},
2020-03-30 22:41:58 +02:00
particle_image = {"minerals_sulfur.png"},
paramtype = "light",
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",
2020-03-30 22:46:01 +02:00
tiles = {"ores_peat.png"},
2020-03-30 22:41:58 +02:00
particle_image = {"ores_peat.png"},
groups = {crumbly=3,drop_on_dig=1,falling_node=1},
sounds = default.node_sound_dirt_defaults(),
})
minetest.register_craft({
type = "fuel",
recipe = "ores:peat",
burntime = 15
})