Godot 4 · GDScript
Tablas de puntaje global
Crear Tablas
Desde el panel, accede a la seccion de Tablas y crea una nueva proporcionando un nombre. Configura el orden, la cantidad de puntajes y los campos de datos extra.
Configuracion de la Tabla
Una vez creada, configura:
- Orden: descendente o ascendente.
- Puntajes a mostrar: cantidad de filas retornadas.
- Puntaje min/max: limites opcionales; los envios fuera de rango se rechazan.
- Campos personalizados: datos extra por puntaje (nivel, pais, etc.), hasta 20 segun tu plan.
- Puntajes temporales: tablas diaria/semanal/mensual. Apagado = tabla solo historica; un envio que no supere el mejor puntaje no guarda nada.
Guarda la clave de cada tabla: la usaras en set_leaderboard.
Multiples Tablas e Indices
Declara todas tus tablas juntas. El orden define el indice con el que las usaras siempre (1, 2, 3...).
Gamdato.set_leaderboard(["clave_1", "clave_2", "clave_3"])
# clave_1 -> tabla 1, clave_2 -> tabla 2, clave_3 -> tabla 3Enviar Puntajes
Envia el puntaje de un jugador a una tabla por su indice, con datos personalizados opcionales:
# Recomendado: reintenta solo si no hay conexion y sobrevive a cierres de la app.
Gamdato.submit_with_retry(1, puntaje, {"nivel": nivel_alcanzado})# submit_completed(success: bool, table_index: int, server_score: int)
# submit_effect(table_index: int, effect: String, periods_enabled: bool)
# effect = "updated" the historic (all-time) score was written
# "periods_only" only the daily/weekly/monthly buckets improved
# "not_improved" nothing was stored (doesn't beat your best)
Gamdato.submit_effect.connect(func(table, effect, periods_enabled):
match effect:
"updated": print("new historic best!")
"periods_only": print("improved a daily/weekly/monthly board")
"not_improved": print("kept your previous best"))submit_with_retry solo reemplaza un score en cola si el nuevo es mayor. Usa submit() para un envio simple sin reintento. La señal submit_effect reporta el efecto exacto: "updated" (score historico escrito), "periods_only" (solo mejoraron las tablas diaria/semanal/mensual) o "not_improved" (no se guardo nada). En tablas con scores temporales desactivados, un score que no supere tu mejor cacheado ni siquiera se envia (la llamada retorna false), consulta get_table_config(table).
Leer Puntajes
Estas funciones devuelven al instante lo ultimo cargado, sin esperar red:
- get_table_data(tabla): El top de la tabla con datos extra.
- get_best_score(tabla) / get_player_pos(tabla): Tu mejor puntaje y tu puesto.
for fila in Gamdato.get_table_data(1):
print("#%d %s %d" % [fila.rank, fila.player_name, fila.score])
print("Tu mejor: %d (puesto %d)" % [Gamdato.get_best_score(1), Gamdato.get_player_pos(1)])# get_table_data(table) -> Array, each row:
{
"rank": int,
"player_key": String,
"player_name": String,
"score": int,
"custom_data": Dictionary
}
# custom_data holds the extra fields you defined for the table in the panel, e.g.:
{
"level": 2,
"country": "Mexico"
}Vistas: Periodos y Amigos
Pide vistas filtradas (diaria, semanal, mensual o solo amigos) y escucha view_loaded:
Gamdato.view_loaded.connect(_on_view)
Gamdato.load_leaderboard_view(1, "weekly") # top semanal
Gamdato.load_leaderboard_view(1, "all", {"friends_only": true}) # solo amigos
func _on_view(tabla, periodo, solo_amigos, scores, mi_score) -> void:
for fila in scores:
print("#%d %s %d" % [fila.rank, fila.player_name, fila.score])# scores: Array, each row:
{
"rank": int,
"player_key": String,
"player_name": String,
"score": int,
"custom_data": Dictionary,
"date": String
}
# player_score: Dictionary (your own row), or null if you have no score:
{
"rank": int,
"score": int,
"custom_data": Dictionary,
"date": String # period bucket the score belongs to
}
# custom_data keys are the extra fields you defined for the table in the panel.
# The response also carries the table's dashboard config:
# "leaderboard": { "name": String, "sort_order": "asc" | "desc", "periods_enabled": bool }
# Period views (daily/weekly/monthly) additionally include "period" and "period_key".Buscar y Ver Jugadores
Busca por nombre o consulta el perfil de otro jugador:
Gamdato.search_players(1, "texto") # -> players_search_completed
Gamdato.load_player_info(player_key) # -> player_info_loaded# players_search_completed -> results: Array, each:
{
"rank": int,
"player_key": String,
"player_name": String,
"score": int
}
# player_info_loaded -> player: Dictionary
{
"player_key": String,
"player_name": String,
"is_invitable": bool,
"created_at": String
}
# ...plus scores: Array, one per leaderboard the player appears on:
{
"leaderboard": {
"table_key": String,
"name": String,
"sort_order": String # "asc" | "desc"
},
"rank": int,
"score": int,
"custom_data": Dictionary,
"date": String,
"updated_at": String
}