Help with generating randomized text options within a label (not entire scene)

I’m having trouble with figuring out how to include random text in a single section of a scene. Each time the player returns to one labelled section, the action should randomize again.

Basically, the entire scene is the ‘Library’. The first time the player enters the library, one paragraph displays. Then, the next time they visit this section and every time they return to the front desk, the librarian should be doing a different action (i.e. if they roll a 1, he’s reading; if they roll a 2, he’s humming; if they roll a 3 he’s working.)

The problem is that every time I look up how to do this, I only find info about setting random variables for an entire scene. Since I want the randomization to occur only in one section within the scene, without the player ever leaving the scene, how would I achieve this?

Here is a rough idea of the code. (I have no idea what I’m doing, though):

"*comment main library scene
*line_break
*if (pc_visitedlibrary = false)
The local library is crammed with seemingly endless rows of books. It smells vaguely of dust and learning. Behind the front desk, the librarian smiles in greeting. “Can I help you find something?”
*elseif
*label frontdeskrandomization
*rand librarian_action 1 3
*if librarian_action = 1
The librarian squints in your direction.
*elseif librarian_action = 2
The librarian stares off into space, as if lost in thought.
*elseif librarian_action = 3
The librarian appears to be sorting through a tall stack of books. "

The only way I’ve done it is via *rand die_roll 1 3
*if die_roll = 1…

Does this work?

*if (pc_visitedlibrary = false)
  *set pc_visitedlibrary true
  The local library is crammed with seemingly endless rows of books. It smells vaguely of dust and learning. Behind the front desk, the librarian smiles in greeting. “Can I help you find something?”
*else
  *label frontdeskrandomization
  *rand librarian_action 1 3
  *if librarian_action = 1
    The librarian squints in your direction.
  *elseif librarian_action = 2
    The librarian stares off into space, as if lost in thought.
  *else
    The librarian appears to be sorting through a tall stack of books.

You forget to set the library variable to true. And please use " ``` " to show your code.

Hi. Thank you for helping me out!
@Loudbeat, I tried pasting that in and I get the error message for the line that has “else”: It is illegal to fall into an *else statement; you must *goto or *finish before the end of the indented block.

It goes directly into a *choice menu after this. So is that why I’m getting this error?

1 Like

Yes, complete the code yourself, you have to use a *goto after the if block.

You can check this post to start learning choicescript.

1 Like

Thank you. I’ll check this out!

1 Like

That snippet will require implicit control flow to function correctly. I’d guess you don’t have it enabled for your script.