Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

greendad37

17
Posts
5
Topics
3
Following
A member registered Sep 09, 2020

Recent community posts

That worked for me. The more that I use this, the more that I like. I highly recommend it. Thank you for creating this and making it available. 

Thank you! I'll try "say" html way to display images. I'm currently learning the syntax so can't offer much at the moment, but my idea was to display a small image when a specific verb is used on an object. I'm hoping something like say <img src='image.jpg'> will work.

Cross posted on Reddit...

I'm joining the party late...downloaded it and am taking it for a spin. I like the design approach: hybrid parser, download finished game into a single HTML file, game data is separated from game engine, editor is HTML based, comes with examples, and a nice PDF manual. I don't see an easy way to include graphics?

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!

@boxofcereal - please let me know if you can grab the files off of my repl.it account - index.html - ramus-2.5.1 - Replit

Below are some changes that I have made to the Ramus script file. I've split the file into three files (css, html, js) to make it easier for me to write stories and modified code, but the instructions below should be easy to do to the single combined file.

Added story information to the HTML
<!-- customization-->

<div id="story-name">Ramus Template</div>

<div id="story-version">1.1</div>

<div id="story-author">Some One</div>

Added restart link in the footer in the HTML

<a href="#" onclick="restart(this);">Restart</a>

Added variable in JavaScript - based on story info in html - used for unique save to localStorage

/* customization: get story name from HTML form

*/

var storyName = document.getElementById("story-name").innerHTML;

Add function in JavaScript to load story data - refresh browser will pick up where you left off

/* customization: load storydata from HTML storage

*/

var storage; 

var fail;

var storydata = {};

loadStory();

START = storydata.location;

moves = storydata.moves;

var total = 0;

for (var i in score)

total += score[i];

function loadStory() {

try {

(storage = JSON.parse(localStorage.getItem(storyName)));

fail && (storage=false);

} catch (exception) {}

if (storage) {

storydata=JSON.parse(localStorage.getItem(storyName) );

moves = storydata.moves;

START = storydata.start;

score = storydata.score;

document.getElementById("moves").innerHTML=moves;

}

else {

START="start";

moves=1;

score={};

visited={};

storydata.location=START; 

storydata.moves=moves;

storydata.score=score;

storydata.visited=visited;

localStorage.setItem(storyName, JSON.stringify(storydata));

}

}

Added save function to localStorage in JavaScript

/* customization: save storydata to HTML storage

*/

function saveStory() {

localStorage.setItem(storyName, JSON.stringify(storydata)); 

}

Added restart function in JavaScript - called by link in footer

/* customization: restart the game from link in footer

*/

function restart(node) {

localStorage.clear(storyName);

if (status_line !== null) status_line.innerHTML = "";

if (moves_line !== null) moves_line.innerHTML = "0";

if (score_line !== null) score_line.innerHTML = "0";

transcript.innerHTML = "";

moves = 1;

score = {};

visited = {};

storydata.moves = moves;

storydata.score = score;

storydata.visited = visited;

storydata.location = START;

saveStory();

if (moves_line !== null)

moves_line.innerText = moves;

advanceStory(start);

}

Modified Ramus function advanceStory - add this at the end of the function

/* customization: autosave storydata

*/

storydata.location=fragment.id; storydata.moves=moves; storydata.score=score; storydata.visited=visited; saveStory();

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

In one of the games that I started on I have a simple card playing scenario to win or lose money in a casino. It is based on a random number comparison; if you "win" you get money added, and if you lose, you have money subtracted. Below is a sample code using Ramus scripting:

#test gte(Math.random(), .6);
#iftrue {{inline(inventory.money =+5)}}
#do localStorage.setItem("_inventory", JSON.stringify(inventory));

In this example, if the random number is greater than .6 you get $5 added to your money.  This assumes you've set up an inventory array at the beginning of the game.  Since there isn't auto-saving variables like Squiffy does, I periodically save to localStorage.

 Additional conditions can be coded such as checking to see if you've visited the casino multiple times (the Dead Leaves example has a test to see if you've tried something 5 times before) or if you've already won a preset casino "house limit."

I look forward to seeing how others have used some of the new Ramus features to code different scenarios. 

The latest version allows you to display a link if a condition has been met. In the example below, the lines were added to the starter template under the DIV ID "part2"

#test visited.start
#iftrue <p>You've visited <a href="#start">start</a>

This simple example first tests whether you have seen a section and if you have, it displays some text and a link. The Dead Leaves example uses this frequently to display a message and link if you've visited before, and something different if you haven't.

Other scenarios that you might find this useful are:

  • Display a link if you have something in your inventory
  • Display a link if a random number generated by JavaScript meets your criteria

These little things help make your text adventure play differently every time you play it. I look forward to seeing other ways this might be used in the comments.

This is a simple inventory hack that I am using.

In the starter template, I added the following code to div id = "start"

#do story = {}; inventory = {}; health = {}; 
#do story.title = "Generic Ramus Template"; inventory.book = false; health.food = 10;
#do localStorage.setItem("_story", JSON.stringify(story));
#do localStorage.setItem("_inventory", JSON.stringify(inventory));
#do localStorage.setItem("_health", JSON.stringify(health));

Throughout the story, I add and change inventory and save it to localStorage.

To display the inventory, I added the following code in the footer section after the moves and score lines:

<a href="#" onclick="return show_inventory(this);">Inventory</a>
 
<script type="text/javascript">
function show_inventory(node) {
displayHealth = {}; displayHealth = JSON.parse(localStorage.getItem("_health") ); alert("Your food level is " + displayHealth.food) ;
}
</script>

I'm sure there are better ways to do this, and look forward to seeing suggestions in the comments.

I posted a message on Reddit, hopefully it helps get more users. 

Interactive Fiction (reddit.com)

(1 edit)

Excited to see the new version and features! 



I recently added auto saving of variables to HTML storage, and a way to restore a game. Information is posted on a Reddit post: Ramus IF scripting : interactivefiction (reddit.com)

My apologies if you've tried this already - I'm new to javascript and am still learning. I have added a couple of new commands at the bottom of your template file and am able to save a variable to localstorage, and then read the value from local storage. 

To test, I used the template.html and at the start, I saved a variable and reset the value, and in a later part of the template I echo'd the current value, restored it, and echo'd the new value. 

I am going to see if I can incorporate into a simple game to test some more but I thought I'd share. 

You've really done a great job at making it simple to create a game.

commands["save"] = function (name, value) {
localStorage.setItem(name, value);
return "";
};

commands["restore"] = function (name) {
value = ( localStorage.getItem(name) );
variables[name] = value;
return "";
};

This is great. Any chance you could add save and restore to/from html storage?