From ef3e6616e95730f8af247d2b9380909d6d784313 Mon Sep 17 00:00:00 2001 From: Niklp Date: Wed, 5 Jun 2024 17:56:45 +0200 Subject: [PATCH] Minor changes (#49) - Optimize textures w/ optipng - Remove mt 0.4 compatibility stuff - Other minor stuff (play sounds ephemeral, tweak style of some comments, ...) --- init.lua | 30 +++++++++++------------------- textures/stamina_hud_bg.png | Bin 81 -> 68 bytes textures/stamina_hud_fg.png | Bin 522 -> 480 bytes textures/stamina_hud_poison.png | Bin 3196 -> 402 bytes 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/init.lua b/init.lua index 318e01c..54f4f24 100644 --- a/init.lua +++ b/init.lua @@ -65,25 +65,17 @@ local function is_player(player) end local function set_player_attribute(player, key, value) - if player.get_meta then - local meta = player:get_meta() - if meta and value == nil then - meta:set_string(key, "") - elseif meta then - meta:set_string(key, tostring(value)) - end + local meta = player:get_meta() + if value == nil then + meta:set_string(key, "") else - player:set_attribute(key, value) + meta:set_string(key, tostring(value)) end end local function get_player_attribute(player, key) - if player.get_meta then - local meta = player:get_meta() - return meta and meta:get_string(key) or "" - else - return player:get_attribute(key) - end + local meta = player:get_meta() + return meta:get_string(key) end local hud_ids_by_player_name = {} @@ -125,7 +117,7 @@ function stamina.update_saturation(player, level) local old = stamina.get_saturation(player) - if level == old then -- To suppress HUD update + if level == old then -- To suppress HUD update return end @@ -162,7 +154,7 @@ function stamina.set_poisoned(player, poisoned) set_player_attribute(player, attribute.poisoned, "yes") else player:hud_change(hud_id, "text", "stamina_hud_fg.png") - set_player_attribute(player, attribute.poisoned, "no") + set_player_attribute(player, attribute.poisoned, nil) end end @@ -244,7 +236,7 @@ function stamina.exhaust_player(player, change, cause) if exhaustion >= settings.exhaust_lvl then exhaustion = exhaustion - settings.exhaust_lvl - stamina.change(player, -1) + stamina.change_saturation(player, -1) end stamina.set_exhaustion(player, exhaustion) @@ -493,7 +485,7 @@ function minetest.do_item_eat(hp_change, replace_with_item, itemstack, player, p stamina.log("action", "%s eats %s for %s stamina", player:get_player_name(), itemname, hp_change) end - minetest.sound_play("stamina_eat", {to_player = player:get_player_name(), gain = 0.7}) + minetest.sound_play("stamina_eat", {to_player = player:get_player_name(), gain = 0.7}, true) if hp_change > 0 then stamina.change_saturation(player, hp_change) @@ -519,7 +511,7 @@ function minetest.do_item_eat(hp_change, replace_with_item, itemstack, player, p end end - return nil -- don't overwrite wield item a second time + return nil -- don't overwrite wield item a second time end minetest.register_on_joinplayer(function(player) diff --git a/textures/stamina_hud_bg.png b/textures/stamina_hud_bg.png index 837f91bb59bb5215e2539ade9a929cdbfe447387..e5b57612534b9c14442f53907049c60c7e27c950 100644 GIT binary patch delta 7 OcmWG^nV>S!Pyql5YXU3) delta 18 ZcmZ<>oS?$RSRCZ;#IWw1%*%<2$^bLa1^EB~ diff --git a/textures/stamina_hud_fg.png b/textures/stamina_hud_fg.png index a5cc2a12339c1fcba9e605fb5cae51aabcefb60c..df7713c6af67fde53b936ce20cd16d2a8f9eaf23 100644 GIT binary patch delta 455 zcmV;&0XY7O1mFXZBYy#>NklGzn<>S@;@3H+^S;0LdH-_; zB=HyU|AKH)R~9=>;9`}Hw?Q<59w(l@*JTMz50bG_(9D2Qv47P8hPuJSad5X!&k`>? z@SIa%=8*E&f`K}4uNS9J(XD1({fg^R@v4f~b-yWjY)}jdm&BFU1|Nd7pqT~3niN)= zpr-C?o6Q?&Mn+FCNn7KcR*nA=q+Kw118qM+eHaQVnNK8 xGM;J7`VM&M%Fp#h{=}CAG>(E_3I6(LdIbpGyh%hsRCt`NlfP?IVHAd+ zivNL21xFVL|C0n#xP+i^QAlWqIyfi|NJ(|Dv}V%5Hsp#oVkM*!2m~Z0v~q__BmSVx zu^J9O+YXXFK0RDIWOP$9wae|CK~=f0DpgaVMO&La$})NH&E#& zD%$+~vu^}o?$HZYky%I0byT~9cGBp57QM}&S`xjm_%#+_9Qu_6s$N6hB5JRpZ_Y(^ z9wYBID%Qb7*4*Z6?s(eRTBXg3JoqO{3N_@-nCrM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