WebCraft
WebCraft copied to clipboard
Saving Worlds
Is there any way you could save these worlds using the built-in localStorage object in javascript?
It may be better to use IndexedDB or WebSQL because localStorage has a 2MB limit ):
I use a type of thing I call "File-Based Programming" when I write web apps most of the time nowadays. I declare a variable without a value at the beginning of the code. It can be set to a JSON object by opening a new file, or be set to a parsed JSON string file. Save it with JSON.stringify and an "a" element with download attribute and dataURL of the JSON variable. It may be helpful here.
I use a type of thing I call "File-Based Programming" when I write web apps most of the time nowadays. I declare a variable without a value at the beginning of the code. It can be set to a JSON object by opening a new file, or be set to a parsed JSON string file. Save it with JSON.stringify and an "a" element with download attribute and dataURL of the JSON variable. It may be helpful here.
Good idea... it is same web tech used by Grav a flat-file CMS.