Справочник функций
Godot 4 · GDScript · Currency & store
get_balances
Fetches the player's currency balances plus the game's currency catalog.
Asynchronous (result via signal)
Signature
get_balances() -> voidWhat it does
GETs /currency/balances (session-auth). balances is an Array of { currency_id, balance }; currencies is an Array of the game's currency metadata { id, code, display_name, icon_url, is_active }. On no active session it pushes a warning and emits balances_loaded([], []) immediately.
Parameters
This function takes no parameters.
How to call it
Connect balances_loaded first, then call get_balances(). Call it again after a purchase, a grant, or returning from a Stripe top-up to refresh the displayed wallet.
Result signal: balances_loaded(balances: Array, currencies: Array)
Example
Gamdato.balances_loaded.connect(_on_balances)
Gamdato.get_balances()
func _on_balances(balances: Array, currencies: Array) -> void:
for b in balances:
print("%s: %d" % [b.currency_id, b.balance])Use cases
- Show the player's coin or gem balance in a shop or HUD.
- Refresh the wallet after a purchase, grant, or top-up completes.