Can you save game data?

Is it possible to have an auto-saving or any type of saving for a game?

Hi @Codeknight999,

You can do that in a number of ways:

  • Use the browser local storage to persist data on the same device/browser (Window: localStorage property - Web APIs | MDN). This is relatively easy to add.

  • Use a remote database (MySQL, Firebase etc.), usually this is paired with some sort of authentication so users can login and retrieve their saved state from different devices/browsers. This is more advanced to add.

Search the forums for posts on both, you will find several related topics.

You can auto-save, automatically call your save method when players reaches certain points of progression.

Or you can have the user save manually from a UI button.

3 Likes

Thanks @Leonidas ,
but is there a way to save variables in a username and password? I could make a sign-in with text elements and save the variables there.

@Codeknight999 The second option that @Leonidas had pointed out above answers the question you are asking. Remote database usage like MySQL and Firebase have built in authentication methods that offer email and password access to a specific user. As stated you can search this forum for similar questions related to this topics. Also, I do know that there are a lot of YouTube videos that show the basics of each.

1 Like

OK, thanks. I am building a SQL “table” on Replit, how do I access it in my javascript code, also can I cloud save my table or add it in the code?

Is there another SQL website I can use or a lerning doc for SQLight? I have never heard of it and that is the only thing Replit has, I am accustued to the

CREATE TABLE newtable (name TEXT);

Kind of stuff

@Codeknight999 There are many resources as stated above to do this. As suggested you can search this forum for information on how others have done this.

https://forum.playcanvas.com/search?q=adding%20external%20scripts

https://forum.playcanvas.com/search?q=Firebase

Also, Playcanvas supports the use of most external libraries.
You can find the place to set these here
image

1 Like