Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

SOLVED How to quit a circular previous()

edited July 2014 in Help! with 1.x
[b][/b]Hi Again,
I'm using sugarcane with a stylesheet that gives me a centre story and a stats/inventory box on the left.
In the stats/inventory box you can click on an inventory item and it will display a description and if you're in the right location it will use the item to solve a puzzle. TheMadExile gave me a hand setting up the stylesheet/script and it works great apart from one thing.

In the inventory item description passage I use [[Return|previous()]] to send the user back from the item description to the main story- I do this because they can obviously click on an inventory item at anytime.

The problem I've now discovered is if they click on an inventory item and get the description but then click on another inventory item they get that description but  now I've created a circular previous() of inventory items and the player cannot get back to the game.

Any ideas on how I can solve this problem?
I don't have any scripting skills and trying to figure out how to do this logically is taxing my feeble brain, so appreciate any ideas
Thanks
nowherecity24

Comments

  • This has come up several times before and there are many possible solutions.  This one is largely automatic (set it and forget it).

    1. Tag all of your inventory passages with a tag unique to them (e.g. inventory).

    2. Put something like the following in a script tagged passage:

    prerender["setReturn"] = function () {
    if (tags().indexOf("inventory") === -1) {
    state.history[0].variables["return"] = passage();
    }
    };
    I used inventory for the tag name there.  If you already have your inventory passages uniquely tagged with something else, then simply replace the instance of inventory in the above code with whatever you're using.

    3. Inside your inventory passages, you'd do something like the following to return:

    [[Return|$return]]
    That will send the player to the last encountered non-inventory passage, whatever it was.
  • What can I say you are a hero
    My game is really coming on now thanks to you
    I'm sure I'll be back again but until then thanks nowherecity24
  • This has come up several times before and there are many possible solutions.  This one is largely automatic (set it and forget it).<br />
    <br />
    1. Tag all of your inventory passages with a tag unique to them (e.g. inventory).<br />
    <br />
    2. Put something like the following in a script tagged passage:<br />

    <br />
    prerender["setReturn"] = function () {<br />
    if (tags().indexOf("inventory") === -1) {<br />
    state.history[0].variables["return"] = passage();<br />
    }<br />
    };<br />
    <br />
    <br />
    I used inventory for the tag name there.  If you already have your inventory passages uniquely tagged with something else, then simply replace the instance of inventory in the above code with whatever you're using.<br />
    <br />
    3. Inside your inventory passages, you'd do something like the following to return:<br />

    <br />
    $return<br />
    <br />
    <br />
    That will send the player to the last encountered non-inventory passage, whatever it was.

    Is there a way to do this in Harlowe?
  • The Harlowe equivalent of TheMadExile's example would be something like the following:

    1. The same as his point 1.

    2. Put something like the following in your story's header passage.
    note: If you don't already have one then create a new passage (you can name it whatever you like but I generally name mine Header) and assign it a header) tag.
    (if: (passage:)'s tags contains "inventory")[(set: $return to (passage:)'s name)]
    
    3. Inside your inventory passages add a link something like the following:
    (link-goto: "Return", $return)
    
Sign In or Register to comment.