From 754f90235971e483a6a0c530f0370c256c84ca8f Mon Sep 17 00:00:00 2001 From: trans_soup <> Date: Mon, 17 Jul 2023 14:01:07 +0200 Subject: [PATCH] mcl_vegan_utils: create compression recipe util create function for registering recipes that compress (and optionally un-compress) items. an example of this in vanilla is wheat being compressable into hay. --- mcl_vegan_utils/craft.lua | 39 +++++++++++++++++++++++++++++++++++++++ mcl_vegan_utils/init.lua | 1 + 2 files changed, 40 insertions(+) create mode 100644 mcl_vegan_utils/craft.lua diff --git a/mcl_vegan_utils/craft.lua b/mcl_vegan_utils/craft.lua new file mode 100644 index 0000000..784bd51 --- /dev/null +++ b/mcl_vegan_utils/craft.lua @@ -0,0 +1,39 @@ +function mcl_vegan.register_compress_recipe (input, output, def) + def = def or {} + + if def.reversible == nil then def.reversible = true end + local reversible = def.reversible + + if def.big == nil then def.big = true end + local big = def.big + + local compress_factor = 4 + if big then compress_factor = 9 end + + if big then + minetest.register_craft({ + output = output, + recipe = { + { input, input, input }, + { input, input, input }, + { input, input, input }, + }, + }) + else + minetest.register_craft({ + output = output, + recipe = { + { input, input }, + { input, input }, + }, + }) + end + + if reversible then + minetest.register_craft({ + type = "shapeless", + output = input .. " " .. compress_factor, + recipe = { output }, + }) + end +end diff --git a/mcl_vegan_utils/init.lua b/mcl_vegan_utils/init.lua index 0b4205d..384858b 100644 --- a/mcl_vegan_utils/init.lua +++ b/mcl_vegan_utils/init.lua @@ -13,3 +13,4 @@ include("farming_node") include("farming_item") include("drops") include("food") +include("craft")