mod - hudbars and hbhunger - settings and format number

* provide settings to customized from menu ui or using set command
This commit is contained in:
mckaygerhard 2023-07-24 00:31:42 -04:00
parent 9bfa018ea1
commit 7d9314ca68
2 changed files with 17 additions and 1 deletions

View File

@ -52,6 +52,13 @@ hbhunger.SAT_MAX = 30 -- maximum satiation points
hbhunger.SAT_INIT = 20 -- initial satiation points hbhunger.SAT_INIT = 20 -- initial satiation points
hbhunger.SAT_HEAL = 15 -- required satiation points to start healing hbhunger.SAT_HEAL = 15 -- required satiation points to start healing
local set
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
set= minetest.settings:get("hbhunger_satiation_place") if set ~= nil then hbhunger.HUNGER_PLACE = tonumber(set) end
set= minetest.settings:get("hbhunger_satiation_move") if set ~= nil then hbhunger.HUNGER_MOVE = tonumber(set) end
set= minetest.settings:get("hbhunger_satiation_lvl") if set ~= nil then hbhunger.HUNGER_LVL = tonumber(set) end
--load custom settings --load custom settings
local set = io.open(minetest.get_modpath("hbhunger").."/hbhunger.conf", "r") local set = io.open(minetest.get_modpath("hbhunger").."/hbhunger.conf", "r")
@ -72,7 +79,7 @@ local sicon = "hbhunger_icon.png"
if hb.settings.bar_type == "progress_bar" then if hb.settings.bar_type == "progress_bar" then
sicon = nil sicon = nil
end end
hb.register_hudbar("satiation", 0xFFFFFF, S("Satiation"), { icon = sicon, bgicon = nil, bar = "hbhunger_bar.png" }, hbhunger.SAT_INIT, hbhunger.SAT_MAX, false, nil, { format_value = "%.1f", format_max_value = "%2d" }) hb.register_hudbar("satiation", 0xFFFFFF, S("Satiation"), { icon = sicon, bgicon = nil, bar = "hbhunger_bar.png" }, hbhunger.SAT_INIT, hbhunger.SAT_MAX, false, nil, { format_value = "%02d", format_max_value = "%02d" })
-- update hud elemtens if value has changed -- update hud elemtens if value has changed
local function update_hud(player) local function update_hud(player)

View File

@ -0,0 +1,9 @@
hbhunger_satiation_tick (Time in seconds after which 1 saturation point is taken) float 1600
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
hbhunger_satiation_sprint_move (exhaustion increased this value if player movement detected) float 0.3
hbhunger_satiation_sprint_lvl (at what exhaustion player satiation gets lowerd) float 160