From 2a7c154cee1af2fc6a239044d72a3e3c604724ed Mon Sep 17 00:00:00 2001 From: BlockMen Date: Mon, 1 Jul 2013 09:39:13 +0200 Subject: [PATCH] Tweak override and add more food --- hunger.lua | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/hunger.lua b/hunger.lua index 36f2ddd..44fcb43 100644 --- a/hunger.lua +++ b/hunger.lua @@ -14,23 +14,37 @@ function hud.item_eat(hunger_change, replace_with_item) end end -local function overwrite(name, hunger_change, as_node) +local function overwrite(name, hunger_change, replace_with_item) local tab = minetest.registered_items[name] if tab == nil then return end - local tab2 = {} - for i,v in pairs(tab) do - tab2[i] = v - end - tab2.on_use = hud.item_eat(hunger_change) - - if as_node then - minetest.register_node(":"..name, tab2) - else - minetest.register_craftitem(":"..name, tab2) - end + tab.on_use = hud.item_eat(hunger_change)--, replace_with_item) + minetest.registered_items[name] = tab end -overwrite("default:apple", 2, true) +overwrite("default:apple", 2) if minetest.get_modpath("farming") ~= nil then - overwrite("farming:bread", 4, false) + overwrite("farming:bread", 4) +end + +if minetest.get_modpath("mobs") ~= nil then + overwrite("mobs:meat", 6) + overwrite("mobs:rat_cooked", 5) +end + +if minetest.get_modpath("moretrees") ~= nil then + overwrite("moretrees:coconut_milk", 1) + overwrite("moretrees:raw_coconut", 2) + overwrite("moretrees:acorn_muffin", 3) + overwrite("moretrees:spruce_nuts", 1) + overwrite("moretrees:pine_nuts", 1) + overwrite("moretrees:fir_nuts", 1) +end + +if minetest.get_modpath("dwarves") ~= nil then + overwrite("dwarves:beer", 2) + overwrite("dwarves:apple_cider", 1) + overwrite("dwarves:midus", 2) + overwrite("dwarves:tequila", 2) + overwrite("dwarves:tequila_with_lime", 2) + overwrite("dwarves:sake", 2) end