Minor changes (#49)

- Optimize textures w/ optipng
- Remove mt 0.4 compatibility stuff
- Other minor stuff (play sounds ephemeral, tweak style of some comments, ...)
This commit is contained in:
Niklp 2024-06-05 17:56:45 +02:00 committed by GitHub
parent 9f1acb4eaa
commit ef3e6616e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 19 deletions

View File

@ -65,25 +65,17 @@ local function is_player(player)
end end
local function set_player_attribute(player, key, value) local function set_player_attribute(player, key, value)
if player.get_meta then
local meta = player:get_meta() local meta = player:get_meta()
if meta and value == nil then if value == nil then
meta:set_string(key, "") meta:set_string(key, "")
elseif meta then
meta:set_string(key, tostring(value))
end
else else
player:set_attribute(key, value) meta:set_string(key, tostring(value))
end end
end end
local function get_player_attribute(player, key) local function get_player_attribute(player, key)
if player.get_meta then
local meta = player:get_meta() local meta = player:get_meta()
return meta and meta:get_string(key) or "" return meta:get_string(key)
else
return player:get_attribute(key)
end
end end
local hud_ids_by_player_name = {} local hud_ids_by_player_name = {}
@ -162,7 +154,7 @@ function stamina.set_poisoned(player, poisoned)
set_player_attribute(player, attribute.poisoned, "yes") set_player_attribute(player, attribute.poisoned, "yes")
else else
player:hud_change(hud_id, "text", "stamina_hud_fg.png") 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
end end
@ -244,7 +236,7 @@ function stamina.exhaust_player(player, change, cause)
if exhaustion >= settings.exhaust_lvl then if exhaustion >= settings.exhaust_lvl then
exhaustion = exhaustion - settings.exhaust_lvl exhaustion = exhaustion - settings.exhaust_lvl
stamina.change(player, -1) stamina.change_saturation(player, -1)
end end
stamina.set_exhaustion(player, exhaustion) 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", stamina.log("action", "%s eats %s for %s stamina",
player:get_player_name(), itemname, hp_change) player:get_player_name(), itemname, hp_change)
end 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 if hp_change > 0 then
stamina.change_saturation(player, hp_change) stamina.change_saturation(player, hp_change)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 B

After

Width:  |  Height:  |  Size: 68 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 522 B

After

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 402 B