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