-
Notifications
You must be signed in to change notification settings - Fork 0
using local filestorage for Game save
Using the FileSaver.js, I'm able to write the Json to disk. The reading is an async operation done with the default FileReader-API.
I extended the window.storage-object with the following functions:
compressLocalSave: false, //this is for debugging (save file uncompressed)
loadFile: function(input){
let file = input.files[0];
let fileReader = new FileReader();
fileReader.onload = function() {
window.storage.rebuildFromSave(fileReader.result,window.storage.compressLocalSave);
div = document.querySelector('#backdrop'); //see save/load dialog
div.parentNode.removeChild(div);
};
fileReader.onerror = function() {
alert(fileReader.error);
};
fileReader.readAsText(file);
return(true);
},
saveFile: function(){
var hash = JSON.stringify({state:window.story.state,
history:window.story.history,checkpointName:window.story.checkpointName});
if(window.storage.compressLocalSave) hash = LZString.compressToBase64(hash);
var filename= window.story.name+"_Save.dat";
var blob = new Blob([hash], {type: "text/plain;charset=utf-8"});
saveAs(blob, filename); //FileSaver API
},
What is twine and interactive fiction
Exampl. SuperSimpleStory
What are storyformats
Why snowman
Setup tweego and snowman
Switching between Tweego and Twine
Snowman template methods
Snowman markup
javascript usage
debugging your story
Common issues with template methods and scripting
Story Telling in general
General concepts for IF
Scenes & Sequels
Designing Puzzles
See here about my js-framework running in snowman:
==> problems & solutions <==