mods - hudbars and hbarmor and hbhunger - player checks and texture minimize

* provide player checks for registering callbacks
* provide spanish translations and backguar compat for older engine
  the translation fallback was provide with upload of mod
* provide depends txt file for older engines
* optimize textures and remove icos as same in hbarmor and hudbars
* not set and icon for bar progress and remove background texture
* provide more simplistic hudbar of hbhunger
This commit is contained in:
mckaygerhard 2023-07-23 22:32:46 -04:00
parent 947d4f098d
commit 41f73142c9
7 changed files with 65 additions and 3 deletions

30
mods/hbhunger/depends.txt Normal file
View File

@ -0,0 +1,30 @@
hudbars
default
flowers?
animalmaterials?
bucket?
bushes?
bushes_classic?
cooking?
creatures?
docfarming?
dwarves?
ethereal?
farming?
farming_plus?
ferns?
fishing?
fruit?
glooptest?
jkanimals?
jkfarming?
jkwine?
kpgmobs?
mobfcooking?
mobs?moretrees?
mtfoods?
mush45?
mushroom?
seaplants?
pizza?
nssm?

View File

@ -1,4 +1,27 @@
local S = minetest.get_translator("hbhunger")
local S
if minetest.get_translator ~= nil then
S = minetest.get_translator("hbhunger") -- 5.x translation function
else
if minetest.get_modpath("intllib") then
dofile(minetest.get_modpath("intllib") .. "/init.lua")
if intllib.make_gettext_pair then
gettext, ngettext = intllib.make_gettext_pair() -- new gettext method
else
gettext = intllib.Getter() -- old text file method
end
S = gettext
else -- boilerplate function
S = function(str, ...)
local args = {...}
return str:gsub("@%d+", function(match)
return args[tonumber(match:sub(2))]
end)
end
end
end
local N = function(s) return s end
if minetest.settings:get_bool("enable_damage") then
@ -45,7 +68,11 @@ dofile(minetest.get_modpath("hbhunger").."/hunger.lua")
dofile(minetest.get_modpath("hbhunger").."/register_foods.lua")
-- register satiation hudbar
hb.register_hudbar("satiation", 0xFFFFFF, S("Satiation"), { icon = "hbhunger_icon.png", bgicon = "hbhunger_bgicon.png", bar = "hbhunger_bar.png" }, hbhunger.SAT_INIT, hbhunger.SAT_MAX, false, nil, { format_value = "%.1f", format_max_value = "%d" })
local sicon = "hbhunger_icon.png"
if hb.settings.bar_type == "progress_bar" then
sicon = nil
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" })
-- update hud elemtens if value has changed
local function update_hud(player)
@ -86,6 +113,7 @@ hbhunger.set_hunger_raw = function(player)
end
minetest.register_on_joinplayer(function(player)
if minetest.is_player(player) then
local name = player:get_player_name()
local inv = player:get_inventory()
inv:set_size("hunger",1)
@ -95,14 +123,16 @@ minetest.register_on_joinplayer(function(player)
hbhunger.poisonings[name] = 0
custom_hud(player)
hbhunger.set_hunger_raw(player)
end
end)
minetest.register_on_respawnplayer(function(player)
-- reset hunger (and save)
local name = player:get_player_name()
if minetest.is_player(player) and name then
hbhunger.hunger[name] = hbhunger.SAT_INIT
hbhunger.set_hunger_raw(player)
hbhunger.exhaustion[name] = 0
end
end)
local main_timer = 0

View File

@ -0,0 +1,2 @@
# textdomain:hbhunger
Satiation=Saciado

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 B

After

Width:  |  Height:  |  Size: 112 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 417 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 522 B

After

Width:  |  Height:  |  Size: 145 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 526 B

After

Width:  |  Height:  |  Size: 192 B