freettrpg/scripts/load.gd

18 lines
337 B
GDScript3
Raw Normal View History

2024-06-18 19:17:42 +02:00
extends Node
func loadJSON(savePath):
var data
if not FileAccess.file_exists(savePath):
return 1
var fileAccess = FileAccess.open(savePath, FileAccess.READ)
var jsonString = fileAccess.get_line()
fileAccess.close()
var json = JSON.new()
var error = json.parse(jsonString)
if error:
return 1
data = json.data
return data