0 votes
by (370 points)
Recently,I'm making a game with sugarcube.It has a lot of choices and passages which is very messy,and i wonder if there is a way so that when you click the link it will show new content in the same passage?And please don't advice me to read the sugarcube document.If i understand it i wouldn't have asked

1 Answer

0 votes
by (44.7k points)
edited by

Yes, you can use the <<switch>> macro to do that.  Some people use that trick to combine a series of passages that have no choices.  For example:

<<if ndef $textGroup>><<set $textGroup = 1>><</if>><<switch $textGroup>>
	<<case 1>>Initial story text.
		<<link "Link Text 1" `passage()`>><</link>>
	<<case 2>>Next story text.
		<<link "Link Text 2" `passage()`>><</link>>
	<<default>>Final story text.
		<<unset $textGroup>>[[Next Passage]]
<</switch>><<if def $textGroup>><<set $textGroup += 1>><</if>>

If you want to add more passages, just add more cases, following the same format as above. Also, make sure that the final passage, in the <<default>> case, does <<unset $textGroup>> to clear out that variable. The final passage can branch to multiple passages without a problem.

The story text doesn't need to be only one line.  It can be mutiple paragraphs.  I just used one line here to keep the sample short.

If you want another passage to go to a specific case above, then set $textGroup to that case number before they go there, like this:

[[Click here to skip to the second case|Combined Passage][$textGroup = 2]]

Hope that helps!  :-)

by (370 points)
A P P R E C I A T E
...