get_hudbar_state: return nil if not initialized
This commit is contained in:
parent
965a67a9c1
commit
881564d441
2
API.md
2
API.md
@ -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
|
||||||
|
1
init.lua
1
init.lua
@ -446,6 +446,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,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user