forked from VoxeLibre/VoxeLibre
Make milk stop food poisoning
This commit is contained in:
parent
d241df3d1a
commit
8ce001a564
|
@ -1 +1,2 @@
|
|||
mcl_core
|
||||
mcl_hunger
|
||||
|
|
|
@ -132,15 +132,22 @@ minetest.register_craftitem("mcl_mobitems:cooked_rabbit", {
|
|||
stack_max = 64,
|
||||
})
|
||||
|
||||
-- TODO: Clear status effects
|
||||
-- TODO: Clear *all* status effects
|
||||
minetest.register_craftitem("mcl_mobitems:milk_bucket", {
|
||||
description = "Milk",
|
||||
_doc_items_longdesc = "Milk is very refreshing can be obtained by using a bucket on a cow. Drinking it will clear all status effects (TODO), but restores no hunger points.",
|
||||
_doc_items_longdesc = "Milk is very refreshing can be obtained by using a bucket on a cow. Drinking it will cure food poisoning (in later versions: all status effects), but restores no hunger points.",
|
||||
_doc_items_usagehelp = "Rightclick to drink the milk.",
|
||||
inventory_image = "mcl_mobitems_bucket_milk.png",
|
||||
wield_image = "mcl_mobitems_bucket_milk.png",
|
||||
on_place = minetest.item_eat(0, "bucket:bucket_empty"),
|
||||
on_secondary_use = minetest.item_eat(0, "bucket:bucket_empty"),
|
||||
-- Clear poisoning when used
|
||||
on_place = function(itemstack, player, pointed_thing)
|
||||
mcl_hunger.stop_poison(player)
|
||||
return minetest.do_item_eat(0, "bucket:bucket_empty", itemstack, player, pointed_thing)
|
||||
end,
|
||||
on_secondary_use = function(itemstack, player, pointed_thing)
|
||||
mcl_hunger.stop_poison(player)
|
||||
return minetest.do_item_eat(0, "bucket:bucket_empty", itemstack, player, pointed_thing)
|
||||
end,
|
||||
stack_max = 1,
|
||||
groups = { food = 3 },
|
||||
})
|
||||
|
|
|
@ -1,5 +1,2 @@
|
|||
hudbars
|
||||
intllib?
|
||||
mcl_farming?
|
||||
mcl_fishing?
|
||||
mcl_mobitems?
|
||||
|
|
|
@ -57,6 +57,10 @@ local function poisonp(tick, time, time_left, damage, exhaustion, player)
|
|||
if not player:is_player() then
|
||||
return
|
||||
end
|
||||
-- Abort if poisonings have been stopped
|
||||
if mcl_hunger.poisonings[player:get_player_name()] == 0 then
|
||||
return
|
||||
end
|
||||
time_left = time_left + tick
|
||||
if time_left < time then
|
||||
minetest.after(tick, poisonp, tick, time, time_left, damage, exhaustion, player)
|
||||
|
@ -76,6 +80,12 @@ local function poisonp(tick, time, time_left, damage, exhaustion, player)
|
|||
|
||||
end
|
||||
|
||||
-- Immediately stop all poisonings for this player
|
||||
function mcl_hunger.stop_poison(player)
|
||||
mcl_hunger.poisonings[player:get_player_name()] = 0
|
||||
hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png")
|
||||
end
|
||||
|
||||
function mcl_hunger.item_eat(hunger_change, replace_with_item, poisontime, poison, exhaust, sound)
|
||||
return function(itemstack, user, pointed_thing)
|
||||
local itemname = itemstack:get_name()
|
||||
|
@ -184,14 +194,11 @@ end)
|
|||
|
||||
-- Apply simple poison effect as long there are no real status effect
|
||||
-- TODO: Remove this when status effects are in place
|
||||
if minetest.get_modpath("mcl_farming") then
|
||||
mcl_hunger.register_food("mcl_farming:potato_item_poison", 1, "", 4, 1, 0)
|
||||
end
|
||||
if minetest.get_modpath("mcl_mobitems") then
|
||||
mcl_hunger.register_food("mcl_mobitems:rotten_flesh", 2, "", 8, 1, 100)
|
||||
mcl_hunger.register_food("mcl_mobitems:chicken_raw", 2, "", 30, 0, 100)
|
||||
mcl_hunger.register_food("mcl_mobitems:spider_eye", 0, "", 4, 1, 0)
|
||||
end
|
||||
if minetest.get_modpath("mcl_fishing") then
|
||||
mcl_hunger.register_food("mcl_fishing:pufferfish_raw", 0, "", 60, 1, 300)
|
||||
end
|
||||
|
||||
mcl_hunger.register_food("mcl_farming:potato_item_poison", 1, "", 4, 1, 0)
|
||||
|
||||
mcl_hunger.register_food("mcl_mobitems:rotten_flesh", 2, "", 8, 1, 100)
|
||||
mcl_hunger.register_food("mcl_mobitems:chicken_raw", 2, "", 30, 0, 100)
|
||||
mcl_hunger.register_food("mcl_mobitems:spider_eye", 0, "", 4, 1, 0)
|
||||
|
||||
mcl_hunger.register_food("mcl_fishing:pufferfish_raw", 0, "", 60, 1, 300)
|
||||
|
|
Loading…
Reference in New Issue