Merge branch 'nil_check_hudbar_state' of fluxionary for hudbar state checks

* another fix for https://codeberg.org/Wuzzy/minetest_hudbars/issues/4
  based on separate callbacks, when we have several mods that rely on
* this solves and close https://codeberg.org/Wuzzy/minetest_hudbars/issues/4
  but will need https://codeberg.org/Wuzzy/minetest_hudbars/pulls/7 also.
* this must be use in join with commit 20843d95cec0fb18516bc3c3ee456254a381ad5b
  of this repository that is a backport of my own fork at @mckaygerhard
This commit is contained in:
mckaygerhard 2023-06-21 12:45:36 -04:00
commit 3e73d3fa50
2 changed files with 2 additions and 1 deletions

2
API.md
View File

@ -187,7 +187,7 @@ Makes a previously hidden HUD bar visible again to a player.
It is also possible to read information about existing HUD bars. It is also possible to read information about existing HUD bars.
### `hb.get_hudbar_state(player, identifier)` ### `hb.get_hudbar_state(player, identifier)`
Returns the current state of the active player's HUD bar. Returns the current state of the active player's HUD bar. Will return `nil` if the hudbar is not initialized.
#### Parameters #### Parameters
* `player`: `ObjectRef` of the player to which the HUD bar belongs to * `player`: `ObjectRef` of the player to which the HUD bar belongs to

View File

@ -485,6 +485,7 @@ end
function hb.get_hudbar_state(player, identifier) function hb.get_hudbar_state(player, identifier)
if not player_exists(player) then return nil end if not player_exists(player) then return nil end
local ref = hb.get_hudtable(identifier).hudstate[player:get_player_name()] local ref = hb.get_hudtable(identifier).hudstate[player:get_player_name()]
if not ref then return nil end
-- Do not forget to update this chunk of code in case the state changes -- Do not forget to update this chunk of code in case the state changes
local copy = { local copy = {
hidden = ref.hidden, hidden = ref.hidden,