1
0
mirror of https://repo.or.cz/minetest_hbarmor.git synced 2024-11-14 14:50:18 +01:00
minetest_hbarmor/hunger.lua

105 lines
3.2 KiB
Lua
Raw Normal View History

2013-06-28 22:58:06 +02:00
function hud.item_eat(hunger_change, replace_with_item)
return function(itemstack, user, pointed_thing)
if itemstack:take_item() ~= nil then
local h = tonumber(hud.hunger[user:get_player_name()])
h=h+hunger_change
2013-06-28 23:03:54 +02:00
if h>30 then h=30 end
2013-06-28 22:58:06 +02:00
hud.hunger[user:get_player_name()]=h
2013-06-28 23:03:54 +02:00
hud.save_hunger(user)
2013-06-28 22:58:06 +02:00
itemstack:add_item(replace_with_item) -- note: replace_with_item is optional
--sound:eat
end
return itemstack
end
end
2013-07-01 09:39:13 +02:00
local function overwrite(name, hunger_change, replace_with_item)
2013-06-28 22:58:06 +02:00
local tab = minetest.registered_items[name]
if tab == nil then return end
2013-07-01 09:39:13 +02:00
tab.on_use = hud.item_eat(hunger_change)--, replace_with_item)
minetest.registered_items[name] = tab
2013-06-28 22:58:06 +02:00
end
2013-07-01 09:57:02 +02:00
minetest.after(0.5, function()--ensure all other mods get loaded
2013-07-01 09:39:13 +02:00
overwrite("default:apple", 2)
2013-06-28 22:58:06 +02:00
if minetest.get_modpath("farming") ~= nil then
2013-07-01 09:39:13 +02:00
overwrite("farming:bread", 4)
end
if minetest.get_modpath("mobs") ~= nil then
overwrite("mobs:meat", 6)
2013-07-01 09:57:02 +02:00
overwrite("mobs:meat_raw", 3)
2013-07-01 09:39:13 +02:00
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)
2013-06-28 22:58:06 +02:00
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 damage
--overwrite("animalmaterials:meat_toxic", 3)-- -5 damage
overwrite("animalmaterials:meat_ostrich", 3)
overwrite("animalmaterials:fish_bluewhite", 2)
overwrite("animalmaterials:fish_clownfish", 2)
end
if minetest.get_modpath("fishing") ~= nil then
overwrite("fishing:fish_raw", 2)
overwrite("fishing:fish", 4)
overwrite("fishing:sushi", 6)
end
2013-07-03 15:14:50 +02:00
if minetest.get_modpath("glooptest") ~= nil then
overwrite("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)
end
if minetest.get_modpath("docfarming") ~= nil then
overwrite("docfarming:carrot", 2)
overwrite("docfarming:cucumber", 2)
overwrite("docfarming:corn", 2)
overwrite("docfarming:potato", 4)
overwrite("docfarming:bakedpotato", 5)
overwrite("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_plus:pumpkin_bread", 4)
overwrite("farming_plus:strawberry_item", 2)
overwrite("farming_plus:tomato_item", 2)
overwrite("farming_plus:potatoe_item", 4)
end
2013-07-01 09:57:02 +02:00
end)