extends Node const HIGHSCORE_FILE_PATH = "highscores.json" func updateHighscore(mapname:String,preset:String,rounds:String,time:float,checkpointtimes:Array[float]): var highscores=loadHighscoreDict() var lasthighscore=loadHighscore(mapname,preset,rounds) if lasthighscore !=null: if time0: return highscores[mapname][preset][rounds][highscores[mapname][preset][rounds].size()-1] #return last entry return {} func loadHighscore(mapname:String,preset:String,rounds:String): var highscoredata=loadHighscoredata(mapname,preset,rounds) if highscoredata != null and highscoredata.has("time"): return highscoredata["time"] return null func loadHighcoreCheckpoints(mapname:String,preset:String,rounds:String): var highscoredata=loadHighscoredata(mapname,preset,rounds) if highscoredata != null and highscoredata.has("checkpoints"): return highscoredata["checkpoints"] return null func loadHighscoreDict(): var file = FileAccess.open(HIGHSCORE_FILE_PATH, FileAccess.READ) if file == null: return {} var content = file.get_as_text() return JSON.parse_string(content) func storeHighscoreDict(content:Dictionary): print("Saved Highscorefile:"+str(content)) var file = FileAccess.open(HIGHSCORE_FILE_PATH, FileAccess.WRITE) file.store_string(JSON.stringify(content, "\t"))