Randomly selecting between multiple scenes

@2Ton and other skilled scripters.

I know it’s possible to select a random scene file, but is it possible to use a goto random within a single scene file? For example, say there’s a central room and from it you can choose #Go adventuring. How would the subsequent goto randomly select one of say, twelve possible adventures?

Also, how would you make some adventres repeat only once and others play multiple times?

I would do


*temp randscene

*rand randscene 1 12

*if randscene=1
	*goto_scene adventure1
*if randscene=2
	*goto_scene adventure2

And so on.

Oh wait did I misread? If you want all the adventures in the same file, just do it as


*temp randscene

*rand randscene 1 12

*if randscene=1
	*goto adventure1
*if randscene=2
	*goto adventure2

instead and be sure to “*label adventure1” etc

#fairygodfeather

And add another variable that monitors if a scene has been played, followed by a reroll to pick another, for the scenes intended to only run once?

Yep.

@FairyGodfeather @ADNox

Remember that, with the latest version of ChoiceScript, *create and *temp commands need to have a value assigned:


*temp variable1 50
*temp variable2 true
*temp variable3 "variable"

The above will work. The below, will not:


*temp variable1

@Redgrave - Only *create requires you to declare a variable in the update. *temp allows but doesn’t require a starting value.

1 Like

Scratch that; the subroutines fatten it.

@Caddmuss ah! Thanks for that! I haven’t had time to play around with the latest version of ChoiceScript but I really must do, it seems.

@FairyGodfeather @ADNox sorry for that, and doubly sorry if I confused you!