Overv / WebCraft

Minecraft clone written in Javascript.
zlib License
386 stars 179 forks source link

Saving Worlds #28

Open andrewgrider opened 6 years ago

andrewgrider commented 6 years ago

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

pkipjames commented 5 years ago

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

pkipjames commented 5 years ago

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.

warengonzaga commented 5 years ago

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.