From 3b398d97416614d03e7897116e1aee8dbf99c384 Mon Sep 17 00:00:00 2001 From: h-v-smacker Date: Wed, 22 Nov 2017 03:10:56 +0300 Subject: Recipes now require variable amount of ingredients --- init.lua | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'init.lua') 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 -- cgit v1.2.3