Godot 4 · GDScript · Leaderboards & scores
load_leaderboard_view
Loads a periodic / filtered leaderboard view; result arrives via view_loaded.
Signature
load_leaderboard_view(table_index: int, period: String = "all", options: Dictionary = {}) -> voidWhat it does
POSTs to /leaderboards/scores (or its daily/weekly/monthly variant) for the requested period and filters and emits view_loaded with the rows plus the player's own row. The response also carries the table's dashboard config in a leaderboard block ({ name, sort_order, periods_enabled }); period views additionally return period and period_key. Plain (unfiltered) views are cached and debounced; friends-only and search-filtered results are always fetched fresh. Does nothing if there's no active session or the period/index is invalid.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| table_index | int | required | Table number to load (1-based: 1, 2, 3…). |
| period | String | "all" | Time window: "all", "daily", "weekly", or "monthly". |
| options | Dictionary | {} | Optional filters: {"search": String, "friends_only": bool}. Omit both for the plain top. |
How to call it
Connect view_loaded first, then call this for daily/weekly/monthly tabs or friends-only / search filters. Note the client may emit view_loaded twice per call: immediately with the cached rows (and player_score = {}) so the UI never opens empty, then again with the fresh fetch. For the plain global top you can also just read get_table_data() synchronously.
Result signal: view_loaded(table_index: int, period: String, friends_only: bool, scores: Array, player_score: Dictionary)
Example
Gamdato.view_loaded.connect(_on_view)
Gamdato.load_leaderboard_view(1, "weekly", {"friends_only": true})
func _on_view(idx: int, period: String, friends_only: bool, scores: Array, my_score: Dictionary) -> void:
for row in scores:
print("#%d %s %d" % [row.rank, row.player_name, row.score])Use cases
- Build daily / weekly / monthly leaderboard tabs.
- Show a friends-only ranking or a name-filtered search result.