mirror of
git://repo.or.cz/minetest_hbhunger.git
synced 2024-12-23 16:30:20 +01:00
Make entire mod a no-op if damage is disabled
This commit is contained in:
parent
8ec358cbfd
commit
f1f33a7fc4
11
init.lua
11
init.lua
@ -1,3 +1,5 @@
|
||||
if minetest.setting_getbool("enable_damage") then
|
||||
|
||||
hunger = {}
|
||||
|
||||
-- HUD statbar values
|
||||
@ -27,10 +29,7 @@ if set then
|
||||
end
|
||||
|
||||
local function custom_hud(player)
|
||||
if minetest.setting_getbool("enable_damage") then
|
||||
--hunger
|
||||
hb.init_hudbar(player, "saturation", hunger.get_hunger(player))
|
||||
end
|
||||
end
|
||||
|
||||
dofile(minetest.get_modpath("hunger").."/hunger.lua")
|
||||
@ -109,7 +108,6 @@ minetest.after(2.5, function()
|
||||
local name = player:get_player_name()
|
||||
|
||||
-- only proceed if damage is enabled
|
||||
if minetest.setting_getbool("enable_damage") then
|
||||
local h = tonumber(hunger.hunger[name])
|
||||
local hp = player:get_hp()
|
||||
if timer > 4 then
|
||||
@ -117,7 +115,7 @@ minetest.after(2.5, function()
|
||||
if h > 15 and hp > 0 and player:get_breath() > 0 then
|
||||
player:set_hp(hp+1)
|
||||
-- or damage player by 1 hp if saturation is < 2 (of 30)
|
||||
elseif h <= 1 and minetest.setting_getbool("enable_damage") then
|
||||
elseif h <= 1 then
|
||||
if hp-1 >= 0 then player:set_hp(hp-1) end
|
||||
end
|
||||
end
|
||||
@ -139,10 +137,11 @@ minetest.after(2.5, function()
|
||||
hunger.handle_node_actions(nil, nil, player)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
if timer > 4 then timer = 0 end
|
||||
if timer2 > HUNGER_HUNGER_TICK then timer2 = 0 end
|
||||
end)
|
||||
end)
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user