summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWuzzy <almikes@aol.com>2016-08-05 14:56:58 +0200
committerWuzzy <almikes@aol.com>2016-08-05 14:56:58 +0200
commit0d1f2fc7cc93ddd684da18699dba12dc5791e32b (patch)
tree663b2279d8a496f353e18347d9d1904360971189
parentbe3d491cf8e44ac1943747729cdb90311a08ae87 (diff)
Generic item_eat overwrite, changes license
-rw-r--r--README.txt7
-rw-r--r--changelog.txt1
-rw-r--r--hunger.lua448
-rw-r--r--init.lua1
4 files changed, 248 insertions, 209 deletions
diff --git a/README.txt b/README.txt
index b3cc19f..bf042d5 100644
--- a/README.txt
+++ b/README.txt
@@ -2,11 +2,12 @@ Minetest mod: Hunger [hbhunger]
===============================
Version: 0.3.3
-License of source code: WTFPL
------------------------------
+License of source code: LGPL v2.1
+---------------------------------
by Wuzzy (2015)
-Forked from the “Better HUD (and hunger)” mod by BlockMen (2013-2014).
+Forked from the “Better HUD (and hunger)” mod by BlockMen (2013-2015),
+most code comes from this mod.
Using the mod:
diff --git a/changelog.txt b/changelog.txt
index e65533c..cb55204 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -20,3 +20,4 @@ Initial release
0.3.2
-----
- Fix another crash
+
diff --git a/hunger.lua b/hunger.lua
index badff58..1bffccd 100644
--- a/hunger.lua
+++ b/hunger.lua
@@ -6,6 +6,48 @@ function hbhunger.load_hunger(player)
hbhunger.get_hunger(player)
end
+-- wrapper for minetest.item_eat (this way we make sure other mods can't break this one)
+local org_eat = core.do_item_eat
+core.do_item_eat = function(hp_change, replace_with_item, itemstack, user, pointed_thing)
+ local old_itemstack = itemstack
+ itemstack = hbhunger.eat(hp_change, replace_with_item, itemstack, user, pointed_thing)
+ for _, callback in pairs(core.registered_on_item_eats) do
+ local result = callback(hp_change, replace_with_item, itemstack, user, pointed_thing, old_itemstack)
+ if result then
+ return result
+ end
+ end
+ return itemstack
+end
+
+-- food functions
+local food = hbhunger.food
+
+function hbhunger.register_food(name, hunger_change, replace_with_item, poisen, heal, sound)
+ food[name] = {}
+ food[name].saturation = hunger_change -- hunger points added
+ food[name].replace = replace_with_item -- what item is given back after eating
+ food[name].poisen = poisen -- time its poisening
+ food[name].healing = heal -- amount of HP
+ food[name].sound = sound -- special sound that is played when eating
+end
+
+function hbhunger.eat(hp_change, replace_with_item, itemstack, user, pointed_thing)
+ local item = itemstack:get_name()
+ local def = food[item]
+ if not def then
+ def = {}
+ if type(hp_change) ~= "number" then
+ hp_change = 1
+ core.log("error", "Wrong on_use() definition for item '" .. item .. "'")
+ end
+ def.saturation = hp_change * 1.3
+ def.replace = replace_with_item
+ end
+ local func = hbhunger.item_eat(def.saturation, def.replace, def.poisen, def.healing, def.sound)
+ return func(itemstack, user, pointed_thing)
+end
+
-- Poison player
local function poisenp(tick, time, time_left, player)
time_left = time_left + tick
@@ -54,98 +96,92 @@ function hbhunger.item_eat(hunger_change, replace_with_item, poisen, heal)
end
end
-local function overwrite(name, hunger_change, replace_with_item, poisen, heal)
- local tab = minetest.registered_items[name]
- if tab == nil then return end
- minetest.override_item(name, {on_use = hbhunger.item_eat(hunger_change, replace_with_item, poisen, heal) })
-end
-
if minetest.get_modpath("default") ~= nil then
- overwrite("default:apple", 2)
+ hbhunger.register_food("default:apple", 2)
end
if minetest.get_modpath("flowers") ~= nil then
- overwrite("flowers:mushroom_brown", 1)
- overwrite("flowers:mushroom_red", 1, "", 3)
+ hbhunger.register_food("flowers:mushroom_brown", 1)
+ hbhunger.register_food("flowers:mushroom_red", 1, "", 3)
end
if minetest.get_modpath("farming") ~= nil then
- overwrite("farming:bread", 4)
+ hbhunger.register_food("farming:bread", 4)
end
if minetest.get_modpath("mobs") ~= nil then
if mobs.mod ~= nil and mobs.mod == "redo" then
- overwrite("mobs:cheese", 4)
- overwrite("mobs:meat", 8)
- overwrite("mobs:meat_raw", 4)
- overwrite("mobs:rat_cooked", 4)
- overwrite("mobs:honey", 2)
- overwrite("mobs:pork_raw", 3, "", 3)
- overwrite("mobs:pork_cooked", 8)
- overwrite("mobs:chicken_cooked", 6)
- overwrite("mobs:chicken_raw", 2, "", 3)
- overwrite("mobs:chicken_egg_fried", 2)
+ hbhunger.register_food("mobs:cheese", 4)
+ hbhunger.register_food("mobs:meat", 8)
+ hbhunger.register_food("mobs:meat_raw", 4)
+ hbhunger.register_food("mobs:rat_cooked", 4)
+ hbhunger.register_food("mobs:honey", 2)
+ hbhunger.register_food("mobs:pork_raw", 3, "", 3)
+ hbhunger.register_food("mobs:pork_cooked", 8)
+ hbhunger.register_food("mobs:chicken_cooked", 6)
+ hbhunger.register_food("mobs:chicken_raw", 2, "", 3)
+ hbhunger.register_food("mobs:chicken_egg_fried", 2)
if minetest.get_modpath("bucket") then
- overwrite("mobs:bucket_milk", 3, "bucket:bucket_empty")
+ hbhunger.register_food("mobs:bucket_milk", 3, "bucket:bucket_empty")
end
else
- overwrite("mobs:meat", 6)
- overwrite("mobs:meat_raw", 3)
- overwrite("mobs:rat_cooked", 5)
+ hbhunger.register_food("mobs:meat", 6)
+ hbhunger.register_food("mobs:meat_raw", 3)
+ hbhunger.register_food("mobs:rat_cooked", 5)
end
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)
+ hbhunger.register_food("moretrees:coconut_milk", 1)
+ hbhunger.register_food("moretrees:raw_coconut", 2)
+ hbhunger.register_food("moretrees:acorn_muffin", 3)
+ hbhunger.register_food("moretrees:spruce_nuts", 1)
+ hbhunger.register_food("moretrees:pine_nuts", 1)
+ hbhunger.register_food("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)
+ hbhunger.register_food("dwarves:beer", 2)
+ hbhunger.register_food("dwarves:apple_cider", 1)
+ hbhunger.register_food("dwarves:midus", 2)
+ hbhunger.register_food("dwarves:tequila", 2)
+ hbhunger.register_food("dwarves:tequila_with_lime", 2)
+ hbhunger.register_food("dwarves:sake", 2)
end
if minetest.get_modpath("animalmaterials") ~= nil then
- overwrite("animalmaterials:milk", 2)
- overwrite("animalmaterials:meat_raw", 3)
- overwrite("animalmaterials:meat_pork", 3)
- overwrite("animalmaterials:meat_beef", 3)
- overwrite("animalmaterials:meat_chicken", 3)
- overwrite("animalmaterials:meat_lamb", 3)
- overwrite("animalmaterials:meat_venison", 3)
- overwrite("animalmaterials:meat_undead", 3, "", 3)
- overwrite("animalmaterials:meat_toxic", 3, "", 5)
- overwrite("animalmaterials:meat_ostrich", 3)
- overwrite("animalmaterials:fish_bluewhite", 2)
- overwrite("animalmaterials:fish_clownfish", 2)
+ hbhunger.register_food("animalmaterials:milk", 2)
+ hbhunger.register_food("animalmaterials:meat_raw", 3)
+ hbhunger.register_food("animalmaterials:meat_pork", 3)
+ hbhunger.register_food("animalmaterials:meat_beef", 3)
+ hbhunger.register_food("animalmaterials:meat_chicken", 3)
+ hbhunger.register_food("animalmaterials:meat_lamb", 3)
+ hbhunger.register_food("animalmaterials:meat_venison", 3)
+ hbhunger.register_food("animalmaterials:meat_undead", 3, "", 3)
+ hbhunger.register_food("animalmaterials:meat_toxic", 3, "", 5)
+ hbhunger.register_food("animalmaterials:meat_ostrich", 3)
+ hbhunger.register_food("animalmaterials:fish_bluewhite", 2)
+ hbhunger.register_food("animalmaterials:fish_clownfish", 2)
end
if minetest.get_modpath("fishing") ~= nil then
- overwrite("fishing:fish_raw", 2)
- overwrite("fishing:fish_cooked", 5)
- overwrite("fishing:sushi", 6)
- overwrite("fishing:shark", 4)
- overwrite("fishing:shark_cooked", 8)
- overwrite("fishing:pike", 4)
- overwrite("fishing:pike_cooked", 8)
+ hbhunger.register_food("fishing:fish_raw", 2)
+ hbhunger.register_food("fishing:fish_cooked", 5)
+ hbhunger.register_food("fishing:sushi", 6)
+ hbhunger.register_food("fishing:shark", 4)
+ hbhunger.register_food("fishing:shark_cooked", 8)
+ hbhunger.register_food("fishing:pike", 4)
+ hbhunger.register_food("fishing:pike_cooked", 8)
end
if minetest.get_modpath("glooptest") ~= nil then
- overwrite("glooptest:kalite_lump", 1)
+ hbhunger.register_food("glooptest:kalite_lump", 1)
end
if minetest.get_modpath("bushes") ~= nil then
- overwrite("bushes:sugar", 1)
- overwrite("bushes:strawberry", 2)
- overwrite("bushes:berry_pie_raw", 3)
- overwrite("bushes:berry_pie_cooked", 4)
- overwrite("bushes:basket_pies", 15)
+ hbhunger.register_food("bushes:sugar", 1)
+ hbhunger.register_food("bushes:strawberry", 2)
+ hbhunger.register_food("bushes:berry_pie_raw", 3)
+ hbhunger.register_food("bushes:berry_pie_cooked", 4)
+ hbhunger.register_food("bushes:basket_pies", 15)
end
if minetest.get_modpath("bushes_classic") then
@@ -159,218 +195,218 @@ if minetest.get_modpath("bushes_classic") then
"mixed_berry"}
for _, berry in ipairs(berries) do
if berry ~= "mixed_berry" then
- overwrite("bushes:"..berry, 1)
+ hbhunger.register_food("bushes:"..berry, 1)
end
- overwrite("bushes:"..berry.."_pie_raw", 2)
- overwrite("bushes:"..berry.."_pie_cooked", 5)
- overwrite("bushes:basket_"..berry, 15)
+ hbhunger.register_food("bushes:"..berry.."_pie_raw", 2)
+ hbhunger.register_food("bushes:"..berry.."_pie_cooked", 5)
+ hbhunger.register_food("bushes:basket_"..berry, 15)
end
end
if minetest.get_modpath("mushroom") ~= nil then
- overwrite("mushroom:brown", 1)
- overwrite("mushroom:red", 1, "", 3)
+ hbhunger.register_food("mushroom:brown", 1)
+ hbhunger.register_food("mushroom:red", 1, "", 3)
-- mushroom potions: red = strong poison, brown = light restorative
if minetest.get_modpath("vessels") then
- overwrite("mushroom:brown_essence", 1, "vessels:glass_bottle", nil, 4)
- overwrite("mushroom:poison", 1, "vessels:glass_bottle", 10)
+ hbhunger.register_food("mushroom:brown_essence", 1, "vessels:glass_bottle", nil, 4)
+ hbhunger.register_food("mushroom:poison", 1, "vessels:glass_bottle", 10)
end
end
if minetest.get_modpath("docfarming") ~= nil then
- overwrite("docfarming:carrot", 3)
- overwrite("docfarming:cucumber", 2)
- overwrite("docfarming:corn", 3)
- overwrite("docfarming:potato", 4)
- overwrite("docfarming:bakedpotato", 5)
- overwrite("docfarming:raspberry", 3)
+ hbhunger.register_food("docfarming:carrot", 3)
+ hbhunger.register_food("docfarming:cucumber", 2)
+ hbhunger.register_food("docfarming:corn", 3)
+ hbhunger.register_food("docfarming:potato", 4)
+ hbhunger.register_food("docfarming:bakedpotato", 5)
+ hbhunger.register_food("docfarming:raspberry", 3)
end
if minetest.get_modpath("farming_plus") ~= nil then
- overwrite("farming_plus:carrot_item", 3)
- overwrite("farming_plus:banana", 2)
- overwrite("farming_plus:orange_item", 2)
- overwrite("farming:pumpkin_bread", 4)
- overwrite("farming_plus:strawberry_item", 2)
- overwrite("farming_plus:tomato_item", 2)
- overwrite("farming_plus:potato_item", 4)
- overwrite("farming_plus:rhubarb_item", 2)
+ hbhunger.register_food("farming_plus:carrot_item", 3)
+ hbhunger.register_food("farming_plus:banana", 2)
+ hbhunger.register_food("farming_plus:orange_item", 2)
+ hbhunger.register_food("farming:pumpkin_bread", 4)
+ hbhunger.register_food("farming_plus:strawberry_item", 2)
+ hbhunger.register_food("farming_plus:tomato_item", 2)
+ hbhunger.register_food("farming_plus:potato_item", 4)
+ hbhunger.register_food("farming_plus:rhubarb_item", 2)
end
if minetest.get_modpath("mtfoods") ~= nil then
- overwrite("mtfoods:dandelion_milk", 1)
- overwrite("mtfoods:sugar", 1)
- overwrite("mtfoods:short_bread", 4)
- overwrite("mtfoods:cream", 1)
- overwrite("mtfoods:chocolate", 2)
- overwrite("mtfoods:cupcake", 2)
- overwrite("mtfoods:strawberry_shortcake", 2)
- overwrite("mtfoods:cake", 3)
- overwrite("mtfoods:chocolate_cake", 3)
- overwrite("mtfoods:carrot_cake", 3)
- overwrite("mtfoods:pie_crust", 3)
- overwrite("mtfoods:apple_pie", 3)
- overwrite("mtfoods:rhubarb_pie", 2)
- overwrite("mtfoods:banana_pie", 3)
- overwrite("mtfoods:pumpkin_pie", 3)
- overwrite("mtfoods:cookies", 2)
- overwrite("mtfoods:mlt_burger", 5)
- overwrite("mtfoods:potato_slices", 2)
- overwrite("mtfoods:potato_chips", 3)
+ hbhunger.register_food("mtfoods:dandelion_milk", 1)
+ hbhunger.register_food("mtfoods:sugar", 1)
+ hbhunger.register_food("mtfoods:short_bread", 4)
+ hbhunger.register_food("mtfoods:cream", 1)
+ hbhunger.register_food("mtfoods:chocolate", 2)
+ hbhunger.register_food("mtfoods:cupcake", 2)
+ hbhunger.register_food("mtfoods:strawberry_shortcake", 2)
+ hbhunger.register_food("mtfoods:cake", 3)
+ hbhunger.register_food("mtfoods:chocolate_cake", 3)
+ hbhunger.register_food("mtfoods:carrot_cake", 3)
+ hbhunger.register_food("mtfoods:pie_crust", 3)
+ hbhunger.register_food("mtfoods:apple_pie", 3)
+ hbhunger.register_food("mtfoods:rhubarb_pie", 2)
+ hbhunger.register_food("mtfoods:banana_pie", 3)
+ hbhunger.register_food("mtfoods:pumpkin_pie", 3)
+ hbhunger.register_food("mtfoods:cookies", 2)
+ hbhunger.register_food("mtfoods:mlt_burger", 5)
+ hbhunger.register_food("mtfoods:potato_slices", 2)
+ hbhunger.register_food("mtfoods:potato_chips", 3)
--mtfoods:medicine
- overwrite("mtfoods:casserole", 3)
- overwrite("mtfoods:glass_flute", 2)
- overwrite("mtfoods:orange_juice", 2)
- overwrite("mtfoods:apple_juice", 2)
- overwrite("mtfoods:apple_cider", 2)
- overwrite("mtfoods:cider_rack", 2)
+ hbhunger.register_food("mtfoods:casserole", 3)
+ hbhunger.register_food("mtfoods:glass_flute", 2)
+ hbhunger.register_food("mtfoods:orange_juice", 2)
+ hbhunger.register_food("mtfoods:apple_juice", 2)
+ hbhunger.register_food("mtfoods:apple_cider", 2)
+ hbhunger.register_food("mtfoods:cider_rack", 2)
end
if minetest.get_modpath("fruit") ~= nil then
- overwrite("fruit:apple", 2)
- overwrite("fruit:pear", 2)
- overwrite("fruit:bananna", 3)
- overwrite("fruit:orange", 2)
+ hbhunger.register_food("fruit:apple", 2)
+ hbhunger.register_food("fruit:pear", 2)
+ hbhunger.register_food("fruit:bananna", 3)
+ hbhunger.register_food("fruit:orange", 2)
end
if minetest.get_modpath("mush45") ~= nil then
- overwrite("mush45:meal", 4)
+ hbhunger.register_food("mush45:meal", 4)
end
if minetest.get_modpath("seaplants") ~= nil then
- overwrite("seaplants:kelpgreen", 1)
- overwrite("seaplants:kelpbrown", 1)
- overwrite("seaplants:seagrassgreen", 1)
- overwrite("seaplants:seagrassred", 1)
- overwrite("seaplants:seasaladmix", 6)
- overwrite("seaplants:kelpgreensalad", 1)
- overwrite("seaplants:kelpbrownsalad", 1)
- overwrite("seaplants:seagrassgreensalad", 1)
- overwrite("seaplants:seagrassgreensalad", 1)
+ hbhunger.register_food("seaplants:kelpgreen", 1)
+ hbhunger.register_food("seaplants:kelpbrown", 1)
+ hbhunger.register_food("seaplants:seagrassgreen", 1)
+ hbhunger.register_food("seaplants:seagrassred", 1)
+ hbhunger.register_food("seaplants:seasaladmix", 6)
+ hbhunger.register_food("seaplants:kelpgreensalad", 1)
+ hbhunger.register_food("seaplants:kelpbrownsalad", 1)
+ hbhunger.register_food("seaplants:seagrassgreensalad", 1)
+ hbhunger.register_food("seaplants:seagrassgreensalad", 1)
end
if minetest.get_modpath("mobfcooking") ~= nil then
- overwrite("mobfcooking:cooked_pork", 6)
- overwrite("mobfcooking:cooked_ostrich", 6)
- overwrite("mobfcooking:cooked_beef", 6)
- overwrite("mobfcooking:cooked_chicken", 6)
- overwrite("mobfcooking:cooked_lamb", 6)
- overwrite("mobfcooking:cooked_venison", 6)
- overwrite("mobfcooking:cooked_fish", 6)
+ hbhunger.register_food("mobfcooking:cooked_pork", 6)
+ hbhunger.register_food("mobfcooking:cooked_ostrich", 6)
+ hbhunger.register_food("mobfcooking:cooked_beef", 6)
+ hbhunger.register_food("mobfcooking:cooked_chicken", 6)
+ hbhunger.register_food("mobfcooking:cooked_lamb", 6)
+ hbhunger.register_food("mobfcooking:cooked_venison", 6)
+ hbhunger.register_food("mobfcooking:cooked_fish", 6)
end
if minetest.get_modpath("creatures") ~= nil then
- overwrite("creatures:meat", 6)
- overwrite("creatures:flesh", 3)
- overwrite("creatures:rotten_flesh", 3, "", 3)
+ hbhunger.register_food("creatures:meat", 6)
+ hbhunger.register_food("creatures:flesh", 3)
+ hbhunger.register_food("creatures:rotten_flesh", 3, "", 3)
end
if minetest.get_modpath("ethereal") then
- overwrite("ethereal:strawberry", 1)
- overwrite("ethereal:banana", 4)
- overwrite("ethereal:pine_nuts", 1)
- overwrite("ethereal:bamboo_sprout", 0, "", 3)
- overwrite("ethereal:fern_tubers", 1)
- overwrite("ethereal:banana_bread", 7)
- overwrite("ethereal:mushroom_plant", 2)
- overwrite("ethereal:coconut_slice", 2)
- overwrite("ethereal:golden_apple", 4, "", nil, 10)
- overwrite("ethereal:wild_onion_plant", 2)
- overwrite("ethereal:mushroom_soup", 4, "ethereal:bowl")
- overwrite("ethereal:mushroom_soup_cooked", 6, "ethereal:bowl")
- overwrite("ethereal:hearty_stew", 6, "ethereal:bowl", 3)
- overwrite("ethereal:hearty_stew_cooked", 10, "ethereal:bowl")
+ hbhunger.register_food("ethereal:strawberry", 1)
+ hbhunger.register_food("ethereal:banana", 4)
+ hbhunger.register_food("ethereal:pine_nuts", 1)
+ hbhunger.register_food("ethereal:bamboo_sprout", 0, "", 3)
+ hbhunger.register_food("ethereal:fern_tubers", 1)
+ hbhunger.register_food("ethereal:banana_bread", 7)
+ hbhunger.register_food("ethereal:mushroom_plant", 2)
+ hbhunger.register_food("ethereal:coconut_slice", 2)
+ hbhunger.register_food("ethereal:golden_apple", 4, "", nil, 10)
+ hbhunger.register_food("ethereal:wild_onion_plant", 2)
+ hbhunger.register_food("ethereal:mushroom_soup", 4, "ethereal:bowl")
+ hbhunger.register_food("ethereal:mushroom_soup_cooked", 6, "ethereal:bowl")
+ hbhunger.register_food("ethereal:hearty_stew", 6, "ethereal:bowl", 3)
+ hbhunger.register_food("ethereal:hearty_stew_cooked", 10, "ethereal:bowl")
if minetest.get_modpath("bucket") then
- overwrite("ethereal:bucket_cactus", 2, "bucket:bucket_empty")
+ hbhunger.register_food("ethereal:bucket_cactus", 2, "bucket:bucket_empty")
end
- overwrite("ethereal:fish_raw", 2)
- overwrite("ethereal:fish_cooked", 5)
- overwrite("ethereal:seaweed", 1)
- overwrite("ethereal:yellowleaves", 1, "", nil, 1)
- overwrite("ethereal:sashimi", 4)
- overwrite("ethereal:orange", 2)
+ hbhunger.register_food("ethereal:fish_raw", 2)
+ hbhunger.register_food("ethereal:fish_cooked", 5)
+ hbhunger.register_food("ethereal:seaweed", 1)
+ hbhunger.register_food("ethereal:yellowleaves", 1, "", nil, 1)
+ hbhunger.register_food("ethereal:sashimi", 4)
+ hbhunger.register_food("ethereal:orange", 2)
end
if minetest.get_modpath("farming") and farming.mod == "redo" then
- overwrite("farming:bread", 6)
- overwrite("farming:potato", 1)
- overwrite("farming:baked_potato", 6)
- overwrite("farming:cucumber", 4)
- overwrite("farming:tomato", 4)
- overwrite("farming:carrot", 3)
- overwrite("farming:carrot_gold", 6, "", nil, 8)
- overwrite("farming:corn", 3)
- overwrite("farming:corn_cob", 5)
- overwrite("farming:melon_slice", 2)
- overwrite("farming:pumpkin_slice", 1)
- overwrite("farming:pumpkin_bread", 9)
- overwrite("farming:coffee_cup", 2, "farming:drinking_cup")
- overwrite("farming:coffee_cup_hot", 3, "farming:drinking_cup", nil, 2)
- overwrite("farming:cookie", 2)
- overwrite("farming:chocolate_dark", 3)
- overwrite("farming:donut", 4)
- overwrite("farming:donut_chocolate", 6)
- overwrite("farming:donut_apple", 6)
- overwrite("farming:raspberries", 1)
- overwrite("farming:blueberries", 1)
- overwrite("farming:muffin_blueberry", 4)
+ hbhunger.register_food("farming:bread", 6)
+ hbhunger.register_food("farming:potato", 1)
+ hbhunger.register_food("farming:baked_potato", 6)
+ hbhunger.register_food("farming:cucumber", 4)
+ hbhunger.register_food("farming:tomato", 4)
+ hbhunger.register_food("farming:carrot", 3)
+ hbhunger.register_food("farming:carrot_gold", 6, "", nil, 8)
+ hbhunger.register_food("farming:corn", 3)
+ hbhunger.register_food("farming:corn_cob", 5)
+ hbhunger.register_food("farming:melon_slice", 2)
+ hbhunger.register_food("farming:pumpkin_slice", 1)
+ hbhunger.register_food("farming:pumpkin_bread", 9)
+ hbhunger.register_food("farming:coffee_cup", 2, "farming:drinking_cup")
+ hbhunger.register_food("farming:coffee_cup_hot", 3, "farming:drinking_cup", nil, 2)
+ hbhunger.register_food("farming:cookie", 2)
+ hbhunger.register_food("farming:chocolate_dark", 3)
+ hbhunger.register_food("farming:donut", 4)
+ hbhunger.register_food("farming:donut_chocolate", 6)
+ hbhunger.register_food("farming:donut_apple", 6)
+ hbhunger.register_food("farming:raspberries", 1)
+ hbhunger.register_food("farming:blueberries", 1)
+ hbhunger.register_food("farming:muffin_blueberry", 4)
if minetest.get_modpath("vessels") then
- overwrite("farming:smoothie_raspberry", 2, "vessels:drinking_glass")
+ hbhunger.register_food("farming:smoothie_raspberry", 2, "vessels:drinking_glass")
end
- overwrite("farming:rhubarb", 1)
- overwrite("farming:rhubarb_pie", 6)
- overwrite("farming:beans", 1)
+ hbhunger.register_food("farming:rhubarb", 1)
+ hbhunger.register_food("farming:rhubarb_pie", 6)
+ hbhunger.register_food("farming:beans", 1)
end
if minetest.get_modpath("kpgmobs") ~= nil then
- overwrite("kpgmobs:uley", 3)
- overwrite("kpgmobs:meat", 6)
- overwrite("kpgmobs:rat_cooked", 5)
- overwrite("kpgmobs:med_cooked", 4)
+ hbhunger.register_food("kpgmobs:uley", 3)
+ hbhunger.register_food("kpgmobs:meat", 6)
+ hbhunger.register_food("kpgmobs:rat_cooked", 5)
+ hbhunger.register_food("kpgmobs:med_cooked", 4)
if minetest.get_modpath("bucket") then
- overwrite("kpgmobs:bucket_milk", 4, "bucket:bucket_empty")
+ hbhunger.register_food("kpgmobs:bucket_milk", 4, "bucket:bucket_empty")
end
end
if minetest.get_modpath("jkfarming") ~= nil then
- overwrite("jkfarming:carrot", 3)
- overwrite("jkfarming:corn", 3)
- overwrite("jkfarming:melon_part", 2)
- overwrite("jkfarming:cake", 3)
+ hbhunger.register_food("jkfarming:carrot", 3)
+ hbhunger.register_food("jkfarming:corn", 3)
+ hbhunger.register_food("jkfarming:melon_part", 2)
+ hbhunger.register_food("jkfarming:cake", 3)
end
if minetest.get_modpath("jkanimals") ~= nil then
- overwrite("jkanimals:meat", 6)
+ hbhunger.register_food("jkanimals:meat", 6)
end
if minetest.get_modpath("jkwine") ~= nil then
- overwrite("jkwine:grapes", 2)
- overwrite("jkwine:winebottle", 1)
+ hbhunger.register_food("jkwine:grapes", 2)
+ hbhunger.register_food("jkwine:winebottle", 1)
end
if minetest.get_modpath("cooking") ~= nil then
- overwrite("cooking:meat_beef_cooked", 4)
- overwrite("cooking:fish_bluewhite_cooked", 3)
- overwrite("cooking:fish_clownfish_cooked", 1)
- overwrite("cooking:meat_chicken_cooked", 2)
- overwrite("cooking:meat_cooked", 2)
- overwrite("cooking:meat_pork_cooked", 3)
- overwrite("cooking:meat_toxic_cooked", -3)
- overwrite("cooking:meat_venison_cooked", 3)
- overwrite("cooking:meat_undead_cooked", 1)
+ hbhunger.register_food("cooking:meat_beef_cooked", 4)
+ hbhunger.register_food("cooking:fish_bluewhite_cooked", 3)
+ hbhunger.register_food("cooking:fish_clownfish_cooked", 1)
+ hbhunger.register_food("cooking:meat_chicken_cooked", 2)
+ hbhunger.register_food("cooking:meat_cooked", 2)
+ hbhunger.register_food("cooking:meat_pork_cooked", 3)
+ hbhunger.register_food("cooking:meat_toxic_cooked", -3)
+ hbhunger.register_food("cooking:meat_venison_cooked", 3)
+ hbhunger.register_food("cooking:meat_undead_cooked", 1)
end
-- ferns mod of plantlife_modpack
if minetest.get_modpath("ferns") ~= nil then
- overwrite("ferns:fiddlehead", 1, "", 1)
- overwrite("ferns:fiddlehead_roasted", 3)
- overwrite("ferns:ferntuber_roasted", 3)
- overwrite("ferns:horsetail_01", 1)
+ hbhunger.register_food("ferns:fiddlehead", 1, "", 1)
+ hbhunger.register_food("ferns:fiddlehead_roasted", 3)
+ hbhunger.register_food("ferns:ferntuber_roasted", 3)
+ hbhunger.register_food("ferns:horsetail_01", 1)
end
if minetest.get_modpath("pizza") ~= nil then
- overwrite("pizza:pizza", 30, "", nil, 30)
- overwrite("pizza:pizzaslice", 5, "", nil, 5)
+ hbhunger.register_food("pizza:pizza", 30, "", nil, 30)
+ hbhunger.register_food("pizza:pizzaslice", 5, "", nil, 5)
end
-- player-action based hunger changes
diff --git a/init.lua b/init.lua
index 8b7eac0..0fb5f31 100644
--- a/init.lua
+++ b/init.lua
@@ -1,6 +1,7 @@
if minetest.setting_getbool("enable_damage") then
hbhunger = {}
+hbhunger.food = {}
-- HUD statbar values
hbhunger.hunger = {}