ambiera home ambiera home

Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name:  Password:
Ambiera Forum > CopperLicht
I created a Save/Load System for CopperLicht. Get it here!
Author Text

wild-master
Registered User
Quote
2018-05-25 23:37:25

Copy the script from this page and save it as a file called "SaveAndLoadData.js":
https://pastebin.com/RpJr1tSr

Your variables will be saved in a text file. Please read the comments in the script for details.

Usage examples:

Use this in your game's main script when you want to save your progress:
SaveFileDialog();

Use this when you want to load your progress:
LoadFileDialog();

You will definitely need to modify it to add the important variables of your games.

This is the best and only practical method that I am aware of for Saving/Loading data with JavaScript/WebGL/HTML.


My testing environment:
Windows 10 Professional, version 1709 (OS Build 16299.371)
Firefox 60.0.1 (64-bit)
Google Chrome 66.0.3359.181 (Official Build) (64-bit)
Microsoft Edge 41.16299.371.0 (HTML 16.16299)
Internet Explorer 11.371.16299.0 (Update Version 11.0.60) (KB4092946)

Works well with:
Firefox
Edge browser

It doesn't work with Internet Explorer.

With Google Chrome, it won't work after one use. I tried to debug it for hours. I saw zero related errors in the console.

When I say "one use", I mean, when you do one action, regardless of whether you Load or Save, the windows for Saving/Loading won't appear again. I thought it might be related to Chrome's well-known problems related to the detection of button-presses and button-releases, but I tried to work around that for hours and I didn't find the answer. With zero console errors that could realistically be related to this, I couldn't debug further. A smarter person would need to fix that problem.


wild-master
Registered User
Quote
2018-05-26 20:25:46

I fixed the problem that happened with the Chrome browser!

The Save/Load window appeared only once with Chrome, even though it appeared every time with Firefox and Edge.

After I fixed that, I noticed another issue. The Load function would also stop working after the first use with Chrome. It would capture the data from the text file correctly the first time, but it wouldn't capture data during consecutive loads, even though it worked repeatedly with Firefox and Edge.

I fixed that problem, too!

Now, Firefox, Chrome, and Edge have the full functionality of the Save/Load script!

I changed the link in the first post. Get the new version there.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internat?onal" (you are not logged in)


Text:

 

  

Forum Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   





Software: Ambiera Light Forum. © 2008-2019 Nikolaus Gebhardt, Ambiera e.U.