add first class support for repixture

This commit is contained in:
unknown 2023-01-27 15:31:51 -05:00
parent 55fae27d05
commit 17662b3f38
3 changed files with 99 additions and 44 deletions

@ -1,5 +1,5 @@
globals = { globals = {
"minetest", "basic_materials", "minetest", "basic_materials", "crafting",
} }
read_globals = { read_globals = {

@ -69,6 +69,25 @@ elseif minetest.get_modpath("fl_ores") and minetest.get_modpath("fl_stone") then
silver_ingot = "fl_ores:iron_ingot", silver_ingot = "fl_ores:iron_ingot",
silicon = "mesecons_materials:silicon", silicon = "mesecons_materials:silicon",
} }
elseif minetest.get_modpath("rp_default") then
materials = {
dirt = "rp_default:dirt",
sand = "rp_default:sand",
gravel = "rp_default:gravel",
steel_ingot = "rp_default:ingot_steel",
gold_ingot = "rp_default:ingot_gold",
mese_crystal_fragment = "rp_default:ingot_steel",
torch = "rp_default:torch",
diamond = "rp_default:pearl",
clay_lump = "rp_default:ingot_steel",
water_bucket = "rp_default:swamp_dirt",
empty_bucket = "rp_default:dirt",
dye_dark_grey = "rp_default:ingot_steel",
copper_ingot = "rp_default:ingot_copper",
tin_ingot = "rp_default:ingot_tin",
silver_ingot = "rp_default:ingot_steel",
silicon = "rp_default:ingot_steel",
}
elseif minetest.get_modpath("hades_core") then elseif minetest.get_modpath("hades_core") then
materials = { materials = {
dirt = "hades_core:dirt", dirt = "hades_core:dirt",
@ -111,8 +130,44 @@ end
local have_hades_materials = minetest.get_modpath("hades_materials") local have_hades_materials = minetest.get_modpath("hades_materials")
local function compress_craft(input)
local buffer = {}
for _, item in pairs(input) do
if type(item)=="table" then
for _, inneritem in pairs(item) do
buffer[inneritem] = (buffer[inneritem] or 0) + 1
end
elseif item ~= "" then
buffer[item] = (buffer[item] or 0) + 1
end
end
local output = {}
for item, count in pairs(buffer) do
output[#output + 1] = item .. " " .. count
end
return output
end
local function register_craft(input)
if minetest.get_modpath("rp_crafting") then
local rp_craft = compress_craft(input.recipe)
if #rp_craft > crafting.MAX_INPUTS then
minetest.log("error", "[basic_materials] unable to register craft for " .. input.output)
return
end
crafting.register_craft({
output = input.output,
items = rp_craft
})
else
minetest.register_craft(input)
end
end
-- Craft recipes -- Craft recipes
minetest.register_craft({ register_craft({
output = "basic_materials:chainlink_brass 12", output = "basic_materials:chainlink_brass 12",
recipe = { recipe = {
{"", "basic_materials:brass_ingot", "basic_materials:brass_ingot"}, {"", "basic_materials:brass_ingot", "basic_materials:brass_ingot"},
@ -121,7 +176,7 @@ minetest.register_craft({
}, },
}) })
minetest.register_craft({ register_craft({
output = "basic_materials:chain_steel 2", output = "basic_materials:chain_steel 2",
recipe = { recipe = {
{"basic_materials:chainlink_steel"}, {"basic_materials:chainlink_steel"},
@ -130,7 +185,7 @@ minetest.register_craft({
} }
}) })
minetest.register_craft({ register_craft({
output = "basic_materials:chain_brass 2", output = "basic_materials:chain_brass 2",
recipe = { recipe = {
{"basic_materials:chainlink_brass"}, {"basic_materials:chainlink_brass"},
@ -139,13 +194,13 @@ minetest.register_craft({
} }
}) })
minetest.register_craft( { register_craft( {
type = "shapeless", type = "shapeless",
output = "basic_materials:brass_ingot 9", output = "basic_materials:brass_ingot 9",
recipe = {"basic_materials:brass_block"}, recipe = {"basic_materials:brass_block"},
}) })
minetest.register_craft( { register_craft( {
output = "basic_materials:brass_block", output = "basic_materials:brass_block",
recipe = { recipe = {
{"basic_materials:brass_ingot", "basic_materials:brass_ingot", "basic_materials:brass_ingot"}, {"basic_materials:brass_ingot", "basic_materials:brass_ingot", "basic_materials:brass_ingot"},
@ -154,14 +209,14 @@ minetest.register_craft( {
}, },
}) })
minetest.register_craft( { register_craft( {
output = "basic_materials:plastic_strip 9", output = "basic_materials:plastic_strip 9",
recipe = { recipe = {
{"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet"} {"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet"}
}, },
}) })
minetest.register_craft( { register_craft( {
output = "basic_materials:empty_spool 3", output = "basic_materials:empty_spool 3",
recipe = { recipe = {
{"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet"}, {"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet"},
@ -172,12 +227,12 @@ minetest.register_craft( {
if have_hades_materials then if have_hades_materials then
minetest.clear_craft({ minetest.clear_craft({
type = "shapeless", type = "shapeless",
recipe = {"group:leaves", "group:leaves", "group:leaves", "group:leaves", "group:leaves", "group:leaves"} recipe = {"group:leaves", "group:leaves", "group:leaves", "group:leaves", "group:leaves", "group:leaves"}
}) })
end end
minetest.register_craft({ register_craft({
type = "shapeless", type = "shapeless",
output = "basic_materials:oil_extract 2", output = "basic_materials:oil_extract 2",
recipe = {"group:leaves", "group:leaves", "group:leaves", "group:leaves", "group:leaves", "group:leaves"} recipe = {"group:leaves", "group:leaves", "group:leaves", "group:leaves", "group:leaves", "group:leaves"}
@ -186,9 +241,9 @@ minetest.register_craft({
-- Cooking recipes -- Cooking recipes
if not have_hades_materials then if not have_hades_materials then
minetest.register_craft({ minetest.register_craft({
type = "cooking", type = "cooking",
output = "basic_materials:plastic_sheet", output = "basic_materials:plastic_sheet",
recipe = "basic_materials:paraffin", recipe = "basic_materials:paraffin",
}) })
end end
@ -224,7 +279,7 @@ minetest.register_craft({
burntime = 30, burntime = 30,
}) })
minetest.register_craft({ register_craft({
output = "basic_materials:concrete_block 6", output = "basic_materials:concrete_block 6",
recipe = { recipe = {
{"group:sand", "basic_materials:wet_cement", materials.gravel}, {"group:sand", "basic_materials:wet_cement", materials.gravel},
@ -233,7 +288,7 @@ minetest.register_craft({
} }
}) })
minetest.register_craft( { register_craft( {
output = "basic_materials:motor 2", output = "basic_materials:motor 2",
recipe = { recipe = {
{materials.mese_crystal_fragment, "basic_materials:copper_wire", "basic_materials:plastic_sheet"}, {materials.mese_crystal_fragment, "basic_materials:copper_wire", "basic_materials:plastic_sheet"},
@ -246,14 +301,14 @@ minetest.register_craft( {
} }
}) })
minetest.register_craft( { register_craft( {
output = "basic_materials:heating_element 2", output = "basic_materials:heating_element 2",
recipe = { recipe = {
{materials.copper_ingot, materials.mese_crystal_fragment, materials.copper_ingot} {materials.copper_ingot, materials.mese_crystal_fragment, materials.copper_ingot}
}, },
}) })
minetest.register_craft({ register_craft({
--type = "shapeless", --type = "shapeless",
output = "basic_materials:energy_crystal_simple 2", output = "basic_materials:energy_crystal_simple 2",
recipe = { recipe = {
@ -262,7 +317,7 @@ minetest.register_craft({
}, },
}) })
minetest.register_craft( { register_craft( {
output = "basic_materials:copper_wire 2", output = "basic_materials:copper_wire 2",
type = "shapeless", type = "shapeless",
recipe = { recipe = {
@ -272,7 +327,7 @@ minetest.register_craft( {
}, },
}) })
minetest.register_craft( { register_craft( {
output = "basic_materials:gold_wire 2", output = "basic_materials:gold_wire 2",
type = "shapeless", type = "shapeless",
recipe = { recipe = {
@ -282,7 +337,7 @@ minetest.register_craft( {
}, },
}) })
minetest.register_craft( { register_craft( {
output = "basic_materials:steel_wire 2", output = "basic_materials:steel_wire 2",
type = "shapeless", type = "shapeless",
recipe = { recipe = {
@ -293,7 +348,7 @@ minetest.register_craft( {
}) })
if materials.stainless_steel_ingot then if materials.stainless_steel_ingot then
minetest.register_craft( { register_craft( {
output = "basic_materials:stainless_steel_wire 2", output = "basic_materials:stainless_steel_wire 2",
type = "shapeless", type = "shapeless",
recipe = { recipe = {
@ -305,7 +360,7 @@ if materials.stainless_steel_ingot then
end end
if materials.aluminum_ingot then if materials.aluminum_ingot then
minetest.register_craft( { register_craft( {
output = "basic_materials:aluminum_wire 2", output = "basic_materials:aluminum_wire 2",
type = "shapeless", type = "shapeless",
recipe = { recipe = {
@ -316,7 +371,7 @@ if materials.aluminum_ingot then
}) })
end end
minetest.register_craft( { register_craft( {
output = "basic_materials:steel_strip 12", output = "basic_materials:steel_strip 12",
recipe = { recipe = {
{"", materials.steel_ingot, ""}, {"", materials.steel_ingot, ""},
@ -324,7 +379,7 @@ minetest.register_craft( {
}, },
}) })
minetest.register_craft( { register_craft( {
output = "basic_materials:copper_strip 12", output = "basic_materials:copper_strip 12",
recipe = { recipe = {
{"", materials.copper_ingot, ""}, {"", materials.copper_ingot, ""},
@ -332,7 +387,7 @@ minetest.register_craft( {
}, },
}) })
minetest.register_craft( { register_craft( {
output = "basic_materials:gold_strip 12", output = "basic_materials:gold_strip 12",
recipe = { recipe = {
{"", materials.gold_ingot, ""}, {"", materials.gold_ingot, ""},
@ -341,7 +396,7 @@ minetest.register_craft( {
}) })
if materials.lead_ingot then if materials.lead_ingot then
minetest.register_craft( { register_craft( {
output = "basic_materials:lead_strip 12", output = "basic_materials:lead_strip 12",
recipe = { recipe = {
{"", materials.lead_ingot, ""}, {"", materials.lead_ingot, ""},
@ -351,7 +406,7 @@ if materials.lead_ingot then
end end
if materials.stainless_steel_ingot then if materials.stainless_steel_ingot then
minetest.register_craft( { register_craft( {
output = "basic_materials:stainless_steel_strip 12", output = "basic_materials:stainless_steel_strip 12",
recipe = { recipe = {
{"", materials.stainless_steel_ingot, ""}, {"", materials.stainless_steel_ingot, ""},
@ -361,7 +416,7 @@ if materials.stainless_steel_ingot then
end end
if materials.aluminum_ingot then if materials.aluminum_ingot then
minetest.register_craft( { register_craft( {
output = "basic_materials:aluminum_strip 12", output = "basic_materials:aluminum_strip 12",
recipe = { recipe = {
{"", materials.aluminum_ingot, ""}, {"", materials.aluminum_ingot, ""},
@ -370,7 +425,7 @@ if materials.aluminum_ingot then
}) })
end end
minetest.register_craft( { register_craft( {
output = "basic_materials:steel_bar 6", output = "basic_materials:steel_bar 6",
recipe = { recipe = {
{"", "", materials.steel_ingot}, {"", "", materials.steel_ingot},
@ -380,7 +435,7 @@ minetest.register_craft( {
}) })
if materials.carbon_steel_ingot then if materials.carbon_steel_ingot then
minetest.register_craft( { register_craft( {
output = "basic_materials:carbon_steel_bar 6", output = "basic_materials:carbon_steel_bar 6",
recipe = { recipe = {
{"", "", materials.carbon_steel_ingot}, {"", "", materials.carbon_steel_ingot},
@ -391,7 +446,7 @@ if materials.carbon_steel_ingot then
end end
if materials.stainless_steel_ingot then if materials.stainless_steel_ingot then
minetest.register_craft( { register_craft( {
output = "basic_materials:stainless_steel_bar 6", output = "basic_materials:stainless_steel_bar 6",
recipe = { recipe = {
{"", "", materials.stainless_steel_ingot}, {"", "", materials.stainless_steel_ingot},
@ -402,7 +457,7 @@ if materials.stainless_steel_ingot then
end end
if materials.aluminum_ingot then if materials.aluminum_ingot then
minetest.register_craft( { register_craft( {
output = "basic_materials:aluminum_bar 6", output = "basic_materials:aluminum_bar 6",
recipe = { recipe = {
{"", "", materials.aluminum_ingot}, {"", "", materials.aluminum_ingot},
@ -412,7 +467,7 @@ if materials.aluminum_ingot then
}) })
end end
minetest.register_craft( { register_craft( {
output = "basic_materials:padlock 2", output = "basic_materials:padlock 2",
recipe = { recipe = {
{"basic_materials:steel_bar"}, {"basic_materials:steel_bar"},
@ -421,7 +476,7 @@ minetest.register_craft( {
}, },
}) })
minetest.register_craft({ register_craft({
output = "basic_materials:chainlink_steel 12", output = "basic_materials:chainlink_steel 12",
recipe = { recipe = {
{"", materials.steel_ingot, materials.steel_ingot}, {"", materials.steel_ingot, materials.steel_ingot},
@ -430,7 +485,7 @@ minetest.register_craft({
}, },
}) })
minetest.register_craft( { register_craft( {
output = "basic_materials:gear_steel 6", output = "basic_materials:gear_steel 6",
recipe = { recipe = {
{"", materials.steel_ingot, ""}, {"", materials.steel_ingot, ""},
@ -439,7 +494,7 @@ minetest.register_craft( {
}, },
}) })
minetest.register_craft( { register_craft( {
type = "shapeless", type = "shapeless",
output = "basic_materials:terracotta_base 8", output = "basic_materials:terracotta_base 8",
recipe = { recipe = {
@ -450,7 +505,7 @@ minetest.register_craft( {
replacements = {{materials.water_bucket, materials.empty_bucket}}, replacements = {{materials.water_bucket, materials.empty_bucket}},
}) })
minetest.register_craft({ register_craft({
type = "shapeless", type = "shapeless",
output = "basic_materials:wet_cement 3", output = "basic_materials:wet_cement 3",
recipe = { recipe = {
@ -464,7 +519,7 @@ minetest.register_craft({
}) })
if not have_hades_materials then if not have_hades_materials then
minetest.register_craft( { register_craft( {
output = materials.silicon.." 4", output = materials.silicon.." 4",
recipe = { recipe = {
{materials.sand, materials.sand}, {materials.sand, materials.sand},
@ -473,7 +528,7 @@ if not have_hades_materials then
}) })
end end
minetest.register_craft( { register_craft( {
output = "basic_materials:ic 4", output = "basic_materials:ic 4",
recipe = { recipe = {
{materials.silicon, materials.silicon}, {materials.silicon, materials.silicon},
@ -482,7 +537,7 @@ minetest.register_craft( {
}) })
-- Without moreores, there still should be a way to create brass. -- Without moreores, there still should be a way to create brass.
minetest.register_craft( { register_craft( {
output = "basic_materials:brass_ingot 9", output = "basic_materials:brass_ingot 9",
recipe = { recipe = {
{materials.copper_ingot, materials.tin_ingot, materials.copper_ingot}, {materials.copper_ingot, materials.tin_ingot, materials.copper_ingot},
@ -492,7 +547,7 @@ minetest.register_craft( {
}) })
if materials.silver_ingot then if materials.silver_ingot then
minetest.register_craft( { register_craft( {
output = "basic_materials:silver_wire 2", output = "basic_materials:silver_wire 2",
type = "shapeless", type = "shapeless",
recipe = { recipe = {
@ -502,7 +557,7 @@ if materials.silver_ingot then
}, },
}) })
minetest.register_craft( { register_craft( {
type = "shapeless", type = "shapeless",
output = "basic_materials:brass_ingot 3", output = "basic_materials:brass_ingot 3",
recipe = { recipe = {

@ -1,3 +1,3 @@
name = basic_materials name = basic_materials
optional_depends = moreores, default, mesecons_materials, dye, bucket, fl_stone, fl_trees, mcl_sounds, hades_core, hades_sounds, hades_materials, hades_dye, hades_bucket, hades_extraores, hades_mesecons_materials, aloz optional_depends = moreores, default, mesecons_materials, dye, bucket, fl_stone, fl_trees, mcl_sounds, hades_core, hades_sounds, hades_materials, hades_dye, hades_bucket, hades_extraores, hades_mesecons_materials, aloz, rp_crafting
min_minetest_version = 5.2.0 min_minetest_version = 5.2.0