test stats anche achievements
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
extends Node
|
||||
|
||||
#Achievement e statistiche devono essere pubblicati live nel backend
|
||||
#Steamworks anche se il gioco non è ancora uscito altrimenti le chiamate ritornano errore
|
||||
### SISETMARE SU RAILS IL FATTORE DI CONVERSIONE DA UNITA' A KM!!!
|
||||
### ORA HO LASCIATO 1:1 PER TEST
|
||||
|
||||
#Achievements and stats must be published on Steam even if game is not yet released
|
||||
#if you have an error setting achievements or stats in debug mode remember to open your steam client
|
||||
#with jmp games account or another account who bought this game. If error persist try to clos and reopen steam client.
|
||||
const KNOWN := [
|
||||
"stat_games_played",
|
||||
"stat_total_score",
|
||||
"stat_distance_km",
|
||||
"stat_stop_number",
|
||||
"stat_photo_number",
|
||||
"stat_toottoot_number",
|
||||
]
|
||||
|
||||
#how it works:
|
||||
@@ -16,6 +22,7 @@ const KNOWN := [
|
||||
# if Stats.get_int("stat_games_played") >= 10:
|
||||
# Achievements.unlock("ACH_PLAY_10_GAMES") #it call storeStats()
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if not SteamManager.is_on_steam:
|
||||
return
|
||||
@@ -32,6 +39,7 @@ func set_int(stat: String, value: int) -> void:
|
||||
if not KNOWN.has(stat):
|
||||
push_warning("Stat not found: %s" % stat)
|
||||
return
|
||||
|
||||
if not Steam.setStatInt(stat, value):
|
||||
push_error("setStatInt failed (incremental with value less than current value? is published on steam?): %s" % stat)
|
||||
|
||||
@@ -39,6 +47,7 @@ func set_float(stat: String, value: float) -> void:
|
||||
if not KNOWN.has(stat):
|
||||
push_warning("Stat not found: %s" % stat)
|
||||
return
|
||||
|
||||
if not Steam.setStatFloat(stat, value):
|
||||
push_error("setStatFloat failed: %s" % stat)
|
||||
|
||||
@@ -59,4 +68,5 @@ func reset_all(include_achievements: bool = false) -> void:
|
||||
Steam.storeStats()
|
||||
|
||||
func _on_stats_stored(_game: int, result: int) -> void:
|
||||
print("Stats save on server, result=%d" % result)
|
||||
if !result:
|
||||
print("stats not ready: (result %d)" % [result])
|
||||
|
||||
Reference in New Issue
Block a user