123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- local rock_def_prototype =
- {
- is_ground_content = true,
- sounds = generic_media.node_sound_stone_defaults(),
- groups = {cracky = 3, stone = 1},
- drop = "cobble",
- }
- local rubble_def_prototype =
- {
- is_ground_content = false,
- groups = {crumbly = 3, falling_node = 1},
- sounds = generic_media.node_sound_gravel_defaults(),
- drop = "cobble",
- }
- local function get_rock_definition(texture)
- local ret = {}
- ret.tiles = {texture}
- for k, v in pairs(rock_def_prototype)
- do
- ret[k] = v
- end
- return ret
- end
- local function get_rubble_definition(texture)
- local ret = {}
- ret.tiles = {texture}
- for k, v in pairs(rubble_def_prototype)
- do
- ret[k] = v
- end
- return ret
- end
- local minerals =
- {
- "coal",
- "iron",
- "gold",
- "diamond",
- get_ore_def_gold = function(parent_rock_name)
- return
- {
- ore_type = "scatter",
- ore = parent_rock_name .. "_with_gold",
- wherein = parent_rock_name .. "_with_iron",
- clust_scarcity = 8 * 8 * 8,
- clust_num_ores = 6,
- clust_size = 3,
- y_min = -30,
- y_max = 1000,
- }
- end,
- get_ore_def_iron = function(parent_rock_name)
- return
- {
- ore_type = "scatter",
- ore = parent_rock_name .. "_with_iron",
- wherein = parent_rock_name .. "_with_coal",
- clust_scarcity = 4 * 4 * 4,
- clust_num_ores = 9,
- clust_size = 3,
- y_min = -30,
- y_max = 1000,
- }
- end,
- get_ore_def_diamond = function(parent_rock_name)
- return
- {
- ore_type = "scatter",
- ore = parent_rock_name .. "_with_diamond",
- wherein = parent_rock_name .. "_with_iron",
- clust_scarcity = 8 * 8 * 8,
- clust_num_ores = 6,
- clust_size = 3,
- y_min = -30,
- y_max = 1000,
- }
- end,
- get_ore_def_coal = function(parent_rock_name)
- return
- {
- ore_type = "vein",
- ore = parent_rock_name .. "_with_coal",
- wherein = parent_rock_name,
- clust_scarcity = 16 * 16 * 16,
- clust_num_ores = 3,
- clust_size = 3,
- y_min = -30,
- y_max = 1000,
- }
- end,
- }
- --TODO: register rubble versions
- local function register_ore_nodes(name, rock_texture, rubble_texture, S)
- for _, mineral in ipairs(minerals)
- do
- local rockdef = get_rock_definition(rock_texture ..
- "^rocks_api_" .. mineral .. "_ore.png")
- local rubbledef = get_rubble_definition(rubble_texture ..
- "^rocks_api_" .. mineral .. "_rubble.png")
- local descr = string.capitalize_first(mineral) .. " Ore"
- rockdef.description = S(descr)
- rubbledef.description = S(descr .. " Rubble")
- rockdef.drop =
- {
- max_items = 3,
- items =
- {
- {rarity = 1, items = {"cobble"}},
- {rarity = 1, items = {mineral}},
- {rarity = 2, items = {mineral}},
- }
- }
- rubbledef.drop = rockdef.drop
- minetest.register_node(name .. "_with_" .. mineral, rockdef)
- minetest.register_ore(minerals["get_ore_def_" .. mineral](name))
- minetest.register_node(name .. "_rubble_with_" .. mineral, rubbledef)
- erosion.register_erosion({name .. "_with_" .. mineral,
- name .. "_rubble_with_" .. mineral})
- end
- end
- function rocks_api.register_rock(name, description, texture, rubble_texture, translation_textdomain)
- local S = minetest.get_translator(translation_textdomain)
- local rockdef = get_rock_definition(texture)
- local rubbledef = get_rubble_definition(rubble_texture)
- rockdef.description = S(description)
- rubbledef.description = S(description .. " Rubble")
- minetest.register_node(name, rockdef)
- minetest.register_node(name .. "_rubble", rubbledef)
- register_ore_nodes(name, texture, rubble_texture, S)
- end
|