Howdy, Stranger!

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

Back to last passage and random generation

Twine version 2.1.0
Sugarcube 2.21.1

I'm currently writing a Twine game for my University assignment but I've got a few obstacles I can't overcome.

Within some of my passages, I've got descriptive passages which appear in multiple locations. I'm having trouble creating a "Back" link which returns to the previous passage.

The other query, I'm trying to create a passage which randomly generates a street of buildings using some basic parts.

StoryInit
<<set $Shops to either("Large grocery store","A small brothel")>>
<<set $House to either("A single room apartment","An unlit dormitory")>>
Streets
While walking through the alleys, you pass <<print $Houses,$Shops,$Houses>>

If someone could be kind enough to help, I'd really appreciate it.

Many thanks

Comments

  • edited March 2017
    Please use the code tag when posting your example - it's the C on the editor bar.

    RW4P wrote: »
    creating a "Back" link which returns to the previous passage.
    You have a number of option available, three of them being: the previous() function, the <<return>> macro, and the <<back>> macro.
    [[Back (remembers all variable changes in this passage)|previous()]]
    
    <<return "Back (remembers all variable changes in this passage)">>
    
    <<back "Back (undoes all variable changes in this passage)">>
    


    RW4P wrote: »
    <<set $Shops to either("Large grocery store","A small brothel")>>
    The either() function returns a randomly selected value from the list given, the above code is assigning that value to the $Shops variables and not a reference to the function itself.

    When showing the random select values in the Streets passage, do you want each value shown to be unique or can the same value appear more than once?

    eg. Is the following output ok? (using underscore to highlight point)
    While walking through the alleys, you pass An unlit dormitory, A small brothel, An unlit dormitory.
  • Thank you very much for your time (and apologies for the slow response - been working/studying).

    I will take the advice and go back to my story, see if it does what I need it to do.
  • In terms of the random select variables, I'd be interested in both unique/the same variations.
    [[Back (remembers all variable changes in this passage)|previous()]]
    
    <<return "Back (remembers all variable changes in this passage)">>
    
    <<back "Back (undoes all variable changes in this passage)">>
    

    ^The return functions work perfectly, thank you very much.
Sign In or Register to comment.