Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | tshrpl |
i’m making an android game which saves the progress to “user://data.json” file
the game crashes, probably because i haven’t set the required permissions in my export settings
what options should be checked to access storage?
i have already checked Read External Storage
and Write External Storage
I guess that’s not the problem.
The problem is not in the options. There must be another problem
ramazan | 2022-01-01 11:56
i have removed the save/load code and the game works just fine
tshrpl | 2022-01-01 12:14
There is a problem with the save code
ramazan | 2022-01-01 12:16
heres the script i’m using
extends Node
const data_path = "user://data.json"
const default_data = {
"bgm": {
"bgm_collection": "city_pop",
"current_track_index": 0
}
}
var global_data
func _ready():
load_data()
func load_data():
var file = File.new()
if not file.file_exists(data_path):
save_data(default_data)
else:
file.open(data_path, File.READ)
var text = file.get_as_text()
global_data = parse_json(text)
# global_data = default_data.duplicate(true)
file.close()
func save_data(data):
var file = File.new()
file.open(data_path, File.WRITE)
file.store_line(to_json(data))
file.close()
global_data = data.duplicate(true)
tshrpl | 2022-01-01 12:19
Have you tried recording on your computer? Is it working
for example:
const data_path = “C:/Users/***/Desktop/my_game/save.json”
ramazan | 2022-01-01 12:24
yes that works perfectly in my desktop
tshrpl | 2022-01-01 12:33
Use the remote debug in the Godot editor to find the exact line where your problem is produced
Wakatta | 2022-01-01 12:55