From 3b398d97416614d03e7897116e1aee8dbf99c384 Mon Sep 17 00:00:00 2001 From: h-v-smacker Date: Wed, 22 Nov 2017 03:10:56 +0300 Subject: [PATCH] Recipes now require variable amount of ingredients --- README.md | 8 ++++++-- init.lua | 32 +++++++++++++------------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index b1c9615..9f8250d 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,12 @@ All products are defined by shapless recipes, and yield items which can be place real world. Although the cans with non-symmetrical items on labels look good only from half of the angles. -The recipes follow the scheme of "glass bottle" + "produce" [ + "sugar" ] +The recipes follow the scheme of "glass bottle" + "produce" × "amount" [ + "sugar" ] -The default 4 items do not require sugar, even though 3 of those are jams and probably +The amount of ingredients differs, roughly based on the original nutritional value of +the items, so that you'd need more less nutricious items to fill a mason jar. + +The default 4 recipes do not require sugar, even though 3 of those are jams and probably would taste horribly IRL without sugar: * Apple jam * Canned brown mushrooms @@ -22,6 +25,7 @@ canning also turns two othwerise inedible objects (in game - such jams do exist Ethereal and farming (redo) mods introduce items that can be canned, too. Some of them (jams) require sugar as the third ingredient. So some of them require both mods. +There also is a jar of honey, which requires honey from mobs/mobs_animal mod. The mason jars with canned food can be put into vessel storage shelves. Or put on display just like the glass vessels can, and destroyed by hand (retreiving the item). diff --git a/init.lua b/init.lua index 079373f..dae9cf0 100644 --- a/init.lua +++ b/init.lua @@ -185,7 +185,7 @@ local canned_food_definitions = { found_in = "mobs_animal", obj_name = "mobs:honey", orig_nutritional_value = 4, - amount = 3, + amount = 4, sugar = false }, @@ -217,12 +217,9 @@ for product, def in pairs(canned_food_definitions) do dig_immediate = 3, attached_node = 1 }, -- canned food prolongs shelf life IRL, but in minetest food never - -- goes bad. Instead, we will reward the effort with 2x higher - -- nutritional value, even if that's not realistic. - -- when (and if) the 'amount' could be taken into account, the - -- rate could also be adjusted + -- goes bad. Here, we increase the nutritional value instead. on_use = minetest.item_eat( - math.floor (def.orig_nutritional_value * 2) + math.floor (def.orig_nutritional_value * def.amount * 0.33) + (def.sugar and 1 or 0), "vessels:glass_bottle"), -- the empty bottle stays, of course sounds = default.node_sound_glass_defaults(), @@ -232,21 +229,18 @@ for product, def in pairs(canned_food_definitions) do -- except for apple: there should be at least 1 jam guaranteed -- to be available in vanilla game (and mushrooms are the guaranteed -- regular - not sweet - canned food) + local ingredients = {"vessels:glass_bottle"} if def.sugar then - minetest.register_craft({ - type = "shapeless", - output = "canned_food:" .. product, - recipe = {"vessels:glass_bottle", "farming:sugar", - def.obj_name}, - }) - else - minetest.register_craft({ - type = "shapeless", - output = "canned_food:" .. product, - recipe = {"vessels:glass_bottle", - def.obj_name}, - }) + table.insert(ingredients, "farming:sugar") end + for i=1,def.amount do + table.insert(ingredients, def.obj_name) + end + minetest.register_craft({ + type = "shapeless", + output = "canned_food:" .. product, + recipe = ingredients + }) end end end