WebCraft icon indicating copy to clipboard operation
WebCraft copied to clipboard

Saving Worlds

Open andrewgrider opened this issue 6 years ago • 3 comments

Is there any way you could save these worlds using the built-in localStorage object in javascript?

andrewgrider avatar Apr 06 '18 01:04 andrewgrider

It may be better to use IndexedDB or WebSQL because localStorage has a 2MB limit ):

pkipjames avatar Apr 12 '19 17:04 pkipjames

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.

pkipjames avatar Apr 12 '19 18:04 pkipjames

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.

warengonzaga avatar Apr 15 '19 16:04 warengonzaga