From 41f73142c98c39ba24071a18dc622686883058ce Mon Sep 17 00:00:00 2001 From: mckaygerhard Date: Sun, 23 Jul 2023 22:32:46 -0400 Subject: [PATCH] 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 --- mods/hbhunger/depends.txt | 30 +++++++++++++++ mods/hbhunger/init.lua | 36 ++++++++++++++++-- mods/hbhunger/locale/hbhunger.es.tr | 2 + .../textures/hbhunger_bar_health_poison.png | Bin 151 -> 112 bytes mods/hbhunger/textures/hbhunger_bgicon.png | Bin 417 -> 0 bytes mods/hbhunger/textures/hbhunger_icon.png | Bin 522 -> 145 bytes .../textures/hbhunger_icon_health_poison.png | Bin 526 -> 192 bytes 7 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 mods/hbhunger/depends.txt create mode 100644 mods/hbhunger/locale/hbhunger.es.tr delete mode 100644 mods/hbhunger/textures/hbhunger_bgicon.png diff --git a/mods/hbhunger/depends.txt b/mods/hbhunger/depends.txt new file mode 100644 index 0000000..1cc6acf --- /dev/null +++ b/mods/hbhunger/depends.txt @@ -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? diff --git a/mods/hbhunger/init.lua b/mods/hbhunger/init.lua index 8d19e16..aec4911 100644 --- a/mods/hbhunger/init.lua +++ b/mods/hbhunger/init.lua @@ -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 diff --git a/mods/hbhunger/locale/hbhunger.es.tr b/mods/hbhunger/locale/hbhunger.es.tr new file mode 100644 index 0000000..0ec642c --- /dev/null +++ b/mods/hbhunger/locale/hbhunger.es.tr @@ -0,0 +1,2 @@ +# textdomain:hbhunger +Satiation=Saciado diff --git a/mods/hbhunger/textures/hbhunger_bar_health_poison.png b/mods/hbhunger/textures/hbhunger_bar_health_poison.png index 255a287f62da4ab60cafeb940b729bb50a0bf30e..516bf6bd3d607e5f82a954ef878711ba0df87621 100644 GIT binary patch delta 94 zcmbQvSTI2%f{~elfq^Z}<~xvLNq6*hWMJ6X&;2Kn7072S4sv&5Sa(k5C6L1$;1l91 swnoVBR>D>wm)q0DF@)oKa>4zopr08CvM{r~^~ delta 133 zcmXSz&NxA$o`a2nfx%|Qx-CG8u{g-xiDBJ2nU_EgTavfC3quG98Ydt83KZci@Q5sC zVBi)8VMc~ob0mO*>?NMQuIvvuSb2plU-JZjgv32v978y+CyPWYf0^G11f7grY||JS YxYjd%ekoD%8mNT9)78&qol`;+0FuQb$N&HU diff --git a/mods/hbhunger/textures/hbhunger_bgicon.png b/mods/hbhunger/textures/hbhunger_bgicon.png deleted file mode 100644 index 07e21e7be47ebfe19f972382f6ea5a086a33cbfc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 417 zcmV;S0bc%zP)pGQ%OWYRCt`Nlf7=jFcd~Z)s4q-V#j}S9N(Bo9uNaUNQ_8GOc{AB z-maBG`8vgdma0hS*v&hyhZwANsZfiVWoIXLI2s_N})-8TUd zjUfaO5kd%1O2HU|rfFcUg;ENPvG<1pBD&Od4Jjq8wTLldwOXO?dsu5Bgg{xAQ?fA& z_WS*8yWNh)7?foR&N5y3eJB7(IRbzSGHX|2bcfQT;6IdIP5z0X~xln_Ed zN(t{hy!V*u7-N@P!PPkj=Nw{;xm#6LIh9fhA%u(&0=I$>BFd4Sb1=q0YmKI9Af<#c z2Gf8i02IYA470=GaOt`(Prq&3%x%}(!$fqwdxhO@hZrMbjOe-!lkg`V?!kF}D%R^Y zQc6fEVX;^s#)y;>Hk%FlzQ@Bw8iwKJ(MJBpU4rBB`1&Wov!Ce`d<6U`HGiA|00000 LNkvXXu0mjf5NEV} diff --git a/mods/hbhunger/textures/hbhunger_icon.png b/mods/hbhunger/textures/hbhunger_icon.png index a5cc2a12339c1fcba9e605fb5cae51aabcefb60c..22447c1c18384e1a6af75823590e978764295e93 100644 GIT binary patch literal 145 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=(3?#Lsx0HZ50X`wFH~Lu4HVSSGV|cbyYNPIL zOQ1MQNswRgZ{{DXxUOWV0r>`=E{-7_*ONJTc~co4hc4t{igP)pGyh%hsRCt`NlfP?IVHAd+ivNL21xFVL|C0n#xP+i^QAlWqIyfi| zNJ(|Dv}V%5Hsp#oVkM*!2m~Z0v~q__BmSVxu^J9O+YXXFK0RD zIWOP$9wae|CK~=f0DpR6MD-+cW1&hnQ0XQr+Wh>pZvIwADLRAaxBv4?74{TPENeux5e{O2973m*1$T%o?iuPB~-Xhx1 zqUJJcrcv`2GHc-ylSjtk_{=X1%2(7bphE|J$)kh(urY^PIn>IBGQ&kc_nDm%_0}w4oO^A8-asU7T M07*qoM6N<$g3~bI&U>cv7h@-A}f&3SRCZ;#IWw1%u67LC%`Af z)xE$+X0L=`5kH43dl*xp5J*u;kY6x^!?PP{K#r@Yi(?4K_2h&G=4GN`>=HW;P0LGo zz{4GT;DDsmOa>JvVTl<|&gKRN?QNz820pyjngCNg-s`njxgN@xNAlpr${ delta 512 zcmV+b0{{KM0geQa7=H)`0000V^Z#K00004VQb$4nuFf3k00006VoOIv08{`}08}$$ z!Sw(D010qNS#tmY3ljhU3ljkVnw%H_000McNliru;0Of`5g@%$npyw=0gg#TK~y-) z#gj2_6G0G#zgatHl2dXiC{PdyP(qp%LFs6b;7?G{Sh(a@P=6x$C6??q1w~?^5Xnu7 zC^1SLoEQ>=kMqr)cPUP1V&x!33SPClnwfoX-i$csxCsn5L^(ffuD;>L`Uhux0lv{xHkd#N@Bd__^N`cWJ$_UMShX4D2PM3<36i@Wp4TbeCB(hj?Iz_IelUt*S)52qGbLA>HvY zp$oAChl~GMogR#_=dM`7*~f1z-?_)HjUnpA*nvY26?rmaa0=tIG4{ zosb@-BwtdJgJg=XepceGq<9V{K|2XDBUz_q`dxPtn*Eyma}pcfn#9{mysbFRXy^Av zcRIO{L0;sUzMFI^-n#npwY$*l*W_=sFGK$OHvR^DhPm9u$eSGi0000