From 83d25276a9ce093b250a032d893040c3d9206dee Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 22 May 2017 08:20:58 +0200 Subject: [PATCH] Fix broken hunger mod when damage disabled --- mods/PLAYER/mcl_hunger/init.lua | 37 +++++++++++++++++++-------------- mods/PLAYER/mcl_sprint/init.lua | 2 +- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/mods/PLAYER/mcl_hunger/init.lua b/mods/PLAYER/mcl_hunger/init.lua index f0123893ab..09ef117d56 100644 --- a/mods/PLAYER/mcl_hunger/init.lua +++ b/mods/PLAYER/mcl_hunger/init.lua @@ -5,9 +5,29 @@ else S = function ( s ) return s end end -if minetest.setting_getbool("enable_damage") then mcl_hunger = {} +mcl_hunger.exhaust = function() end + +mcl_hunger.HUD_TICK = 0.1 + +-- Exhaustion increase +mcl_hunger.EXHAUST_DIG = 5 -- after digging node +mcl_hunger.EXHAUST_JUMP = 50 -- jump +mcl_hunger.EXHAUST_SPRINT_JUMP = 200 -- TODO: jump while sprinting +mcl_hunger.EXHAUST_ATTACK = 100 -- hit an enemy +mcl_hunger.EXHAUST_SWIM = 10 -- TODO: player movement in water +mcl_hunger.EXHAUST_SPRINT = 100 -- sprint (per node) +mcl_hunger.EXHAUST_DAMAGE = 100 -- TODO (mostly done): taking damage (protected by armor) +mcl_hunger.EXHAUST_REGEN = 6000 -- Regenerate 1 HP +mcl_hunger.EXHAUST_LVL = 4000 -- at what exhaustion player saturation gets lowered + +mcl_hunger.SATURATION_INIT = 50 -- Initial saturation for new/respawning players + +mcl_hunger.active = false + +if minetest.setting_getbool("enable_damage") then +mcl_hunger.active = true mcl_hunger.food = {} -- Debug Mode. If enabled, saturation and exhaustion are shown as well. @@ -34,21 +54,6 @@ mcl_hunger.poisonings = {} -- HUD item ids local hunger_hud = {} -mcl_hunger.HUD_TICK = 0.1 - --- Exhaustion increase -mcl_hunger.EXHAUST_DIG = 5 -- after digging node -mcl_hunger.EXHAUST_JUMP = 50 -- jump -mcl_hunger.EXHAUST_SPRINT_JUMP = 200 -- TODO: jump while sprinting -mcl_hunger.EXHAUST_ATTACK = 100 -- hit an enemy -mcl_hunger.EXHAUST_SWIM = 10 -- TODO: player movement in water -mcl_hunger.EXHAUST_SPRINT = 100 -- sprint (per node) -mcl_hunger.EXHAUST_DAMAGE = 100 -- TODO (mostly done): taking damage (protected by armor) -mcl_hunger.EXHAUST_REGEN = 6000 -- Regenerate 1 HP -mcl_hunger.EXHAUST_LVL = 4000 -- at what exhaustion player saturation gets lowered - -mcl_hunger.SATURATION_INIT = 50 -- Initial saturation for new/respawning players - --load custom settings local set = io.open(minetest.get_modpath("mcl_hunger").."/mcl_hunger.conf", "r") if set then diff --git a/mods/PLAYER/mcl_sprint/init.lua b/mods/PLAYER/mcl_sprint/init.lua index f3783e5168..13fe970025 100644 --- a/mods/PLAYER/mcl_sprint/init.lua +++ b/mods/PLAYER/mcl_sprint/init.lua @@ -82,7 +82,7 @@ minetest.register_globalstep(function(dtime) if players[playerName]["shouldSprint"] == true then --Stopped local sprinting -- Prevent sprinting if standing on soul sand or hungry - if playerplus[playerName].nod_stand == "mcl_nether:soul_sand" or (mcl_hunger and mcl_hunger.get_hunger(player) <= 6) then + if playerplus[playerName].nod_stand == "mcl_nether:soul_sand" or (mcl_hunger.active and mcl_hunger.get_hunger(player) <= 6) then sprinting = false else sprinting = true