+1 vote
by (250 points)

I need to somehow jump to a random passage at different points in my game, but I can't work out how to do it. I found this explanation of how to do it on Harlowe but not Sugarcube: https://twinery.org/forum/discussion/5292/jump-to-random-passage

For example, if the player clicks on one of these three buttons, I want it to leap to a random passage -- and have three possible ones that might come up. I've built my game in Sugarcube and Twine 2. I'm using buttons as well, to make the links look good. Any help much appreciated!

Some of the residents in the neighbourhood where your land is have started to ask questions about why it has been vacant for so long. You're wondering what to do.

<div class="wrapper">\
<span class="fixed-buttons">\
<<button "[[Hold onto it, and see if there are measures you can take to increase its value even more.]]">>...<</button>>\
</span>\
</div>\

<div class="wrapper">\
<span class="fixed-buttons">\
<<button "[[Hold onto it and do nothing.]]">>...<</button>>\
</span>\
</div>\

<div class="wrapper">\
<span class="fixed-buttons">\
<<button "[[Sell it for €265,000.]]">>...<</button>>\
</span>\
</div>\

 

 

 

 

1 Answer

0 votes
by (63.1k points)

Try something like this: 

<<set _psg to either(
    'passage 1',
    'passage 2',
    'passage 3'
)>>
<<button 'link text' _psg>><</button>>

Or, shorter but less readable: 

<<button 'link text' `either('passage 1', 'passage 2', 'passage 3')`>><</button>>

 

by (68.6k points)

Chapel's answer is a good one. yes

BTW: You do not need to quote square bracketed links as you're doing.  All macros which accept links, do so directly.  For example:

→ BAD
<<button "[[Hold onto it and do nothing.]]">>...<</button>>\

→ GOOD
<<button [[Hold onto it and do nothing.]]>>...<</button>>\

 

...