Howdy, Stranger!

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

avoiding 'previous()' limbo...

Ok, so I have a strange situation, involving the brilliant 'previous()' function thingy, that lets you go back without having to specify where "back" is.  (http://twinery.org/wiki/twine_1.4_release_notes#macro_syntax_functions).

In the game that I am making, I have several "item" pages added to the menu (map, inventory, sword, etc).  Each of them ends with a "back" link: [[Back|previous()]], thus making it possible to visit the menu pages at any time without losing your place within the game.  HOWEVER, if you to visit a menu page, and then click directly onto another menu page link (and thus not using the back link), you become trapped in a limbo between the two.  For example: you click on "inventory."  Then, instead of hitting "back," you click on "map."  Now the map's [[back|previous()]] will send you to... the inventory.  Click on inventory's [[back|previous()]], and it'll send you to the map, and so on...

It's not a major issue.  I can write a warning to people to always use the "back" links.  But does anyone know a more elegant solution?  Is there a way around this?  maybe some kind of combination of visited() and previous()?  I've yet to learn any javascript...

Comments

  • One way might be to maintain a last-important-page-visited variable -- if you're displaying a sidebar in every passage for your menu links, but not displaying that sidebar in the menu, it might be simple to add a line like
    <<set $last to state.history[0].passage.title>>
    to it, and then, in your menus, use a link like
    [[Back|$last]]
    rather than previous().
  • I guess I'd better implement something... kind of hard to think of an alternative function with a different algorithm, though...

    P.S: In Twine 1.4.1 you can use passage() instead of state.history[0].passage.title.
  • Something like the inverse of bookmark tags, maybe? Have a way to link back to the last page that hasn't been tagged with unimportant... though I don't know how widespread this specific use case is, compared to the similar but distinct case here that might also be worth some built-in support.
  • I posted about this a few days ago
    http://twinery.org/forum/index.php/topic,708.0.html

    I think it's really something we should take a look at. As L said, though, it's hard to think of an alternative way.
  • xax wrote:

    One way might be to maintain a last-important-page-visited variable -- if you're displaying a sidebar in every passage for your menu links, but not displaying that sidebar in the menu, it might be simple to add a line like
    <<set $last to state.history[0].passage.title>>
    to it, and then, in your menus, use a link like
    [[Back|$last]]
    rather than previous().


    Ok, so I AM using the actual menu to display links to their own passages for the items, but I tried this method and it worked anyway.  It means I'll have to add <<set $last to state.history[0].passage.title>> to every regular passage in the entire thing, which is a bit cumbersome, but at least it'll work!  Thanks for the idea.
  • L wrote:

    I guess I'd better implement something... kind of hard to think of an alternative function with a different algorithm, though...

    P.S: In Twine 1.4.1 you can use passage() instead of state.history[0].passage.title.


    Would you be able to give a syntax example of how to use that for the scenario in this thread?

    I have the exact same problem with a inventory passage that has other links pertaining to the inventory, so I get the same looping problem.  Would passage() have to be used in every passage like in the work around someone suggested?

    Thanks.


    **Update**

    I worked this out in the end with the same method already mentioned in this thread. Using something like this <<set $pasHist to passage()>> in every passage and then in say, an inventory passage using [[Back|$pasHist]].
  • In your inventory pages:
    <<silently>>
    <<if $last is ""*unknown*">><<set $last to previous()>><<endif>>
    <<endsilently>>
    text

    [[Back|$last][$last to "*unknown*"]]
    ...and hoping that the value of $last gets updated AFTER your destination has been read from it.  If it doesn't you'll need to use an extra variable to keep track of whether or not you are in a menu page.

    The advantage is that you only need to code it in your inventory pages...
Sign In or Register to comment.