ExchangeClone/zzzz_exchangeclone_init/init.lua

62 lines
2.6 KiB
Lua
Raw Normal View History

2023-12-15 00:09:59 +01:00
exchangeclone = {recipes = {}, base_energy_values = {}, group_values = {}}
if (not minetest.get_modpath("mcl_core")) and (not minetest.get_modpath("default")) then
2023-12-18 23:57:30 +01:00
error("ExchangeClone requires Minetest Game, MineClone2, or MineClonia (and possibly variant subgames).\nPlease use one of those games.")
2023-12-15 00:09:59 +01:00
else
exchangeclone.mcl = minetest.get_modpath("mcl_core")
end
exchangeclone.mineclonia = minetest.get_game_info().id == "mineclonia" -- if exchangeclone.mineclonia, exchangeclone.mcl is also defined.
exchangeclone.pipeworks = minetest.get_modpath("pipeworks")
2023-12-18 23:57:30 +01:00
exchangeclone.orb_max = minetest.settings:get("exchangeclone.orb_max") or 51200000 -- Max capacity of Klein Star Omega in ProjectE
exchangeclone.keep_data = minetest.settings:get_bool("exchangeclone.keep_data", false)
2023-12-15 00:09:59 +01:00
local modpath = minetest.get_modpath("zzzz_exchangeclone_init")
dofile(modpath.."/lib.lua")
2023-12-18 23:57:30 +01:00
-- Override crafting
local old_func = minetest.register_craft
function minetest.register_craft(data, ...)
local itemstring = ItemStack(data.output):get_name()
local allowed = true
-- Skip thousands of banner recipes in MCL2
-- This does mean that if other banner recipes exist that don't use wool (or carpet),
-- they will be ignored in MCL2... but I can't think of a better way to do this.
if exchangeclone.mcl and not exchangeclone.mineclonia then
if itemstring:sub(1, #"mcl_banners:") == "mcl_banners:" then
allowed = false
if data.type and data.type == "shaped" then
for _, row in ipairs(data.recipe) do
for _, item in ipairs(row) do
if item:sub(1, #"mcl_wool:") == "mcl_wool:" then
allowed = true
break
end
end
if allowed then break end
end
end
end
end
if allowed then
exchangeclone.register_craft(data)
end
old_func(data, ...)
end
2023-12-15 00:09:59 +01:00
exchangeclone.register_craft_type("shaped", "shaped")
exchangeclone.register_craft_type("shapeless", "shapeless")
exchangeclone.register_craft_type("cooking", "cooking")
if minetest.get_modpath("technic") then
exchangeclone.register_craft_type("technic", "shapeless")
function exchangeclone.register_technic_recipe(typename, recipe)
local data = technic.recipes[typename]
if data.output_size == 1 then
local result = {recipe = recipe.input, output = recipe.output, type = "technic"}
exchangeclone.register_craft(result)
end
end
end
dofile(modpath.."/base_energy_values.lua")