Hello everyone,
I like how Ramus is contained in a single file, but for writing multiple games I found it easier to split it out into separate CSS, HTML, and JS files. They can be put back into a single file for distribution.
One of the modifications I did was to save where in the story you are so that you can pick back up later.
Below are the three changes:
Added in the HTML file or section:
<!-- customization-->
<div id="game-name">Ramus Template</div>
<div id="game-version">1.0</div>
<div id="game-author">Some One</div>
Added in the JS file or section:
/*
Add a function to get game data from the html
*/
var gameName = document.getElementById("game-name").innerHTML;
console.log(gameName);
/*
Add a function to read START from localStorage and set START to that
value if it exists
*/
var storage;
var fail;
var gamedata = {};
try {
(storage = JSON.parse(localStorage.getItem(gameName)));
fail && (storage=false);
} catch (exception) {}
if (storage) {
gamedata=JSON.parse(localStorage.getItem(gameName) );
console.log(gamedata.location)
}
else {
gamedata.location="start";
localStorage.setItem(gameName, JSON.stringify(gamedata));
}
START = gamedata.location;
Added to each chapter:
#do gamedata.location = "PUT YOUR PAGE ID HERE"; localStorage.setItem(gameName, JSON.stringify(gamedata));
I haven't figured out yet how to not have to add the #do command for each chapter, but if there is a way to grab the current <div id> in javascript then it seems like it would be easy to add something in the advanceStory function()