Howdy, Stranger!

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

like macro that remember variables?

I suspect that the answer to this is probably that I should just stop being lazy. But anyway, here it goes.
I wished there was a macro that quickly  links  to the "parent" passage of a passage.
() previous doesn't get the job done, because if, for example:  I have a passage that's a room, then a wardrobe, then a drawer, and all of them have previous ()  at the end , I would get caught in a loop between wardrobe and drawer when going back from drawer. 
It would also need to remember any variable changes when going back.
Is there a more automated way of doing this than writing customized links  for going back in every passage? It can be a bit bothersome when there's a lot of exploring.

Comments

  • Just set a variable at the beginning of each passage? I haven't tried it but theoretically it should work.
    <<set $parentpassage to Wardrobe>>
    I don't know how Twine's internal structure finds links, so anything else I'd have to experiment with. Alternately you could do something like:
    <<set $Wardrobeparentpassage to state.history[1].passage.title>>
    But neither are the kind of magic solution you're looking for.
  • This is how me and my gangsta friends roll:

    <<set $playboy = "notFound">>

    Bedroom
    You're in a bedroom. There is a chest of drawers here.
    <<display 'Choices'>>

    Choices
    [[Search room.|Search]]
    [[Check first drawer.|First Drawer]]
    [[Check second.|Second]]
    [[Check third.|Third]]

    Search
    You find nothing.
    <<display 'Choices'>>

    First Drawer
    Clothes.
    <<display 'Choices'>>

    Second
    Socks.
    <<display 'Choices'>>

    Third
    Underwear.
    <<if $playboy eq "notFound">>[[Look through underwear|Underwear][$playboy = "found"]]<<endif>>
    <<display 'Choices'>>

    Underwear
    You find dad's Playboy magazines!
    <<display 'Choices'>>
  • Thank you, Sharpe!
    I found a fundamental flaw in the logic I was proposing though.
    It would be impossible to have a macro that returns you to the "Parent Passage" since passages can have more than one parent. How would Twine know?
    So yeah. This works just fine :) Cheers
  • Ummm. So in the bedroom, simply:
    <<set $backtrack to passage()>>
    Then to backtrack, simply:
    [[back|$backtrack]]
    ...that should take you back to the bedroom.  Don't set the $backtrack variable in the wardrobe or the drawers and it'll still be pointing to the bedroom.

    If there are options in the bedroom you want to break the backtrack chain then
    [[Give up|Hallway][$backtrack to ""]]
    ...just incase they find their way to another backtrack link without passing through another backtrackable location.

    A more complicated solution would use an array as a stack that backtrackable locations would push themselves onto and the backtrack would pop them off of.  Not got the variables for tracking what's where sorted yet though I suspect it should be doable with a <<backtrackable>> macro for the checkpoints and a tail on the backtrack links to flag that a backtrack is happening.  It would differ from rewind in that it would not undo variable updates that have occured...
Sign In or Register to comment.