wrong if clause for hunger
parent
44d8abcd3e
commit
b7fde7dc3f
12
init.lua
12
init.lua
|
@ -91,6 +91,10 @@ local function guess_reason(player)
|
|||
local node = minetest.registered_nodes[minetest.get_node(player:getpos()).name]
|
||||
local pos = player:getpos()
|
||||
local reas_meas="default"
|
||||
local lstamina = 10
|
||||
local lthirsty = 10
|
||||
local lsunburn = 0
|
||||
local lhunger = 0
|
||||
pos.x = math.floor(pos.x + 0.5)
|
||||
pos.y = math.floor(pos.y + 0.5)
|
||||
pos.z = math.floor(pos.z + 0.5)
|
||||
|
@ -99,7 +103,7 @@ local function guess_reason(player)
|
|||
lstamina = get_int_attribute(player, "stamina:level")
|
||||
end
|
||||
if mhbhunger ~= nil then
|
||||
lstamina = tonumber(hbhunger.hunger[player_name])
|
||||
lhunger = tonumber(hbhunger.hunger[player_name])
|
||||
end
|
||||
if mthirsty ~= nil then
|
||||
lthirsty = thirsty.get_thirst_factor(player)
|
||||
|
@ -128,6 +132,8 @@ local function guess_reason(player)
|
|||
reas_meas="toxic"
|
||||
elseif lthirsty <= 1 then
|
||||
reas_meas="thirst"
|
||||
elseif lhunger <= 1 then
|
||||
reas_meas="hunger"
|
||||
elseif lstamina <= 1 then
|
||||
reas_meas="exhausted"
|
||||
elseif lsunburn >= 19 then
|
||||
|
@ -139,7 +145,7 @@ local function guess_reason(player)
|
|||
end
|
||||
|
||||
minetest.register_on_dieplayer(function(player,reason)
|
||||
reas_meas="default"
|
||||
local reas_meas="default"
|
||||
local player_name = player:get_player_name()
|
||||
if minetest.is_singleplayer() then
|
||||
player_name = "You"
|
||||
|
@ -150,7 +156,7 @@ minetest.register_on_dieplayer(function(player,reason)
|
|||
if reason == nil then
|
||||
reas_meas=guess_reason(player)
|
||||
else
|
||||
-- print(dump2(reason))
|
||||
print(dump2(reason))
|
||||
if reason.type ~= nil then
|
||||
if (reason.type == "fall") or (reason.type == "punch") or (reason.type == "drawn") then
|
||||
reas_mean = reason.type
|
||||
|
|
Loading…
Reference in New Issue