Compare commits

...

2 Commits

Author SHA1 Message Date
mckaygerhard 9489ee052d hudbars+hbhunger+hbarmor - fix armor bar set to 0% due old loading engines
* for minetest 0.4.16 and 0.4.17 loading of mods is a pain, the
  `on_mods_loaded` still do not exits and only using dependency
  we can get sure a mod its present.
  hudbars need armors parts be present and 100% lodaed to property
  check the armor.def so made optional dependencies only in depends.txt
  cos mod.conf is for newer engines and those works perfectly.
  This only happened at player join or initialization, due
  several errors in the already buggy 3d_armor mod, check:
  https://github.com/minetest-mods/3d_armor/issues/49
2023-08-06 01:16:03 -04:00
mckaygerhard 047649d519 hudbars+hbhunger+hbarmor - permit to gain life if are in good shape 2023-08-06 01:14:31 -04:00
6 changed files with 21 additions and 6 deletions

View File

@ -20,7 +20,7 @@ this mod will place them accordingly.
* Eating an apple (from Minetest Game) increases your satiation by 2
> Warning: Eating food will not directly increase your health anymore, as long as the food
item is supported by this mod (see below).
item is supported by this mod and direct healing is not configured (see below).
> Warning: ! Some foods may be poisoned. If you eat a poisoned item, you may still get a satiation
boost, but for a brief period you lose health points because of food poisoning. However,
@ -55,6 +55,7 @@ This mod adds a hunger buildin mechanic to the game. Players get a new attribute
* At 1 or 0 satiation you will suffer damage and die in case you don't eat something
* If your satiation is 16 or higher, you will slowly regenerate health points
* Eating food will increase your satiation (Duh!)
* Eating food will randomly give you healt life if you configured (see below)
All mods which add food through standard measures (`minetest.item_eat`) are already
supported automatically. Poisoned food needs special support.
@ -124,6 +125,7 @@ Use the advanced settings menu in Minetest for detailed configuration.
| hudbars_hp_player_maximun | set the maximun hp of the player healt | int | 10 20 60 |
| hudbars_br_player_maximun | set the maximun player breath value | int | 10 10 30 |
| hbarmor_autohide | Automatically hide armor HUD bar | bool | false |
| hbarmor_permitgainhp | Randomly gain healt too when eating | bool | true |
| hbhunger_satiation_tick | Time in seconds which 1 saturation point is taken | float | 800 |
| hbhunger_satiation_sprint_dig | exhaustion increased this value after digged node | float | 3 |
| hbhunger_satiation_sprint_place | exhaustion increased this value after placed | float | 1 |

View File

@ -52,6 +52,8 @@ hb.settings.br_player_maximun = hb.load_setting("hudbars_br_player_maximun", "nu
hbarmor.autohide = (true and not hb.settings.forceload_default_hudbars)
hbhunger.permitgainhp = true
hbhunger.HUD_TICK = 0.2
hbhunger.HUNGER_TICK = 800 -- time in seconds after that 1 hunger point is taken
@ -65,6 +67,7 @@ hbhunger.SAT_HEAL = 15 -- required satiation points to start healing
local set
set = minetest.settings:get_bool("hbhunger_permitgainhp") if set ~= nil then hbhunger.permitgainhp = set end
set = minetest.settings:get_bool("hbarmor_autohide") if set ~= nil then hbarmor.autohide = set end
set = minetest.settings:get("hbhunger_satiation_tick") if set ~= nil then hbhunger.HUNGER_TICK = tonumber(set) end
set = minetest.settings:get("hbhunger_satiation_dig") if set ~= nil then hbhunger.HUNGER_DIG = tonumber(set) end

View File

@ -1,6 +1,9 @@
default?
intllib?
3d_armor?
3d_armor_gloves?
shields?
wieldview?
flowers?
animalmaterials?
bucket?

View File

@ -112,7 +112,13 @@ function hbhunger.item_eat(hunger_change, replace_with_item, poisen, heal, sound
-- heal is not defines due way of hbhunger.register_food
if not heal then heal = 1 end
-- eating something not give you inmediate life, give you statiation to get recovery
if hp < 6 and heal > 0 then hp = hp + heal end
if hp < 6 and hp > 0 and heal > 0 then hp = hp + heal end
-- so if you are in good shape and losing healt just give it only for one chance, NSSM specific
if hbhunger.permitgainhp then
local hpreca = math.random (6, 10)
local hprecb = math.random (11, hb.settings.hp_player_maximun - 1)
if hp < hprecb and hp > hpreca then hp = hp + 1 end
end
-- so do not hardcoded hp to 20 when eating
if hp > max_hp then hp = max_hp end
-- this will work only when valid then

View File

@ -623,6 +623,7 @@ if not modhbarm and modarmors then
function hbarmor.get_armor(player)
if not player or not armor.def then
minetest.log("error", "[hbarmor] Call to hbarmor.get_armor cannot do it cos the payer armor definition its not set at this moment!")
return false
end
local name = player:get_player_name()
@ -631,7 +632,7 @@ if not modhbarm and modarmors then
if def and def.state and def.count then
hbarmor.set_armor(name, def.state, def.count)
else
minetest.log("error", "[hudbars] Call to hbarmor.get_armor returned with false!")
minetest.log("error", "[hudbars] Call to hbarmor.get_armor returned with false! armor.def[player] invalid")
return false
end
return true
@ -669,11 +670,9 @@ local function custom_hud(player)
hb.init_hudbar(player, "breath", math.min(breath, breath_max), breath_max, hide_breath)
if not modhbarm and modarmors then
local arm = tonumber(hbarmor.armor[name])
if not arm then arm = 0 end
local arm = tonumber(hbarmor.armor[name] or 0)
local hide_ar = hbarmor.autohide and must_hide(name, arm)
hbarmor.get_armor(player)
arm = tonumber(hbarmor.armor[name])
hb.init_hudbar(player, "armor", arm_printable(arm), 100, hide_ar)
end

View File

@ -128,6 +128,8 @@ hudbars_br_player_maximun (maximun value of braeth of player) int 20
#armor. Otherwise, the armor bar shows “0%”.
hbarmor_autohide (Automatically hide armor HUD bar) bool false
hbhunger_permitgainhp (Permit slowly to gain hp when eating food and not only using satiation) bool true
hbhunger_satiation_tick (Time in seconds after which 1 saturation point is taken) float 800
hbhunger_satiation_sprint_dig (exhaustion increased this value after digged node) float 3