0 votes
extends Label

var level = 1
var savesystemnumber = 0
var savepath

func save():
var SaveFile = File.new()
var data: Dictionary ={"lvl":level,
SaveFile.open("user://lvlss.dat", File.WRITE)

func loadsystem():
var SaveFile = File.new()
if !SaveFile.fileexists("user://lvlss.dat"):
var data = SaveFile.get
level = data["lvl"]
savesystemnumber = data["number"]

Godot version 3.5.1
in Engine by (24 points)

You haven't described what the actual problem is...

Save works in Windows, but doesn't work in Android.

When I close and reopen the game on Windows, I can continue where I left off, but on Android this does not work.

I don't see anything inherently wrong with the posted code, though since it's not formatted as code for the forum, some details are being lost...

That said, a few questions / comments:

  • Is the save file being created but not loaded on Android, or is it not being created? I assume it's not being created.
  • If see the load call just silently returns if the save file doesn't exist.
  • I'd guess this is likely a permissions issue on your Android device. You could / should add some more error checking to the code to help spot the problem.
  • You can always set up a remote debugging session on the device to better spot the problem...
  • I'd recommend that you put your filename in a single variable and reference it in all the places where you have a hardcoded name now. That'll prevent any unintended differences in the name(s)...

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.