Fix hunger crash
This commit is contained in:
parent
22cf4452c6
commit
0174b486f2
@ -138,8 +138,9 @@ function hunger.set_poisoned(player, poisoned)
|
|||||||
player:get_meta():set_string(attribute.poisoned, attr)
|
player:get_meta():set_string(attribute.poisoned, attr)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function poison_tick(player, ticks, interval, elapsed)
|
local function poison_tick(name, ticks, interval, elapsed)
|
||||||
if not hunger.is_poisoned(player) then
|
local player = minetest.get_player_by_name(name)
|
||||||
|
if not player or not hunger.is_poisoned(player) then
|
||||||
return
|
return
|
||||||
elseif elapsed > ticks then
|
elseif elapsed > ticks then
|
||||||
hunger.set_poisoned(player, false)
|
hunger.set_poisoned(player, false)
|
||||||
@ -148,7 +149,7 @@ local function poison_tick(player, ticks, interval, elapsed)
|
|||||||
if hp > 0 then
|
if hp > 0 then
|
||||||
player:set_hp(hp)
|
player:set_hp(hp)
|
||||||
end
|
end
|
||||||
core.after(interval, poison_tick, player, ticks, interval, elapsed + 1)
|
core.after(interval, poison_tick, name, ticks, interval, elapsed + 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -169,7 +170,7 @@ function hunger.poison(player, ticks, interval)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
hunger.set_poisoned(player, true)
|
hunger.set_poisoned(player, true)
|
||||||
poison_tick(player, ticks, interval, 0)
|
poison_tick(player:get_player_name(), ticks, interval, 0)
|
||||||
end
|
end
|
||||||
--- END POISON API ---
|
--- END POISON API ---
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user