Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Ramus 2.5 split and modifications

A topic by greendad37 created May 14, 2022 Views: 114 Replies: 2
Viewing posts 1 to 2

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()

Developer

You could have changed the advanceStory function to set a global variable for example.

(+1)

Thanks - I figured out what I was trying to do and uploaded to my repl.it account -  index.html - ramus-2.5.1 - Replit

The story will always pick up where you left it unless you clear the localstorage via the menu option or from the browser.

Thanks for putting together a great easy to use engine!