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

**URL:** <https://forum.choiceofgames.com/t/help-with-generating-randomized-text-options-within-a-label-not-entire-scene/149566>\
**Category:** ChoiceScript Help\
**Created:** [February 21, 2024, 9:45pm UTC](https://forum.choiceofgames.com/t/help-with-generating-randomized-text-options-within-a-label-not-entire-scene/149566 "2024-02-21T21:45:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![erinskye](https://avatars.discourse-cdn.com/v4/letter/e/2acd7d/32.png) [@erinskye](https://forum.choiceofgames.com/u/erinskye)\
**Post date:** [February 21, 2024, 9:45pm UTC](https://forum.choiceofgames.com/t/help-with-generating-randomized-text-options-within-a-label-not-entire-scene/149566/1 "2024-02-21T21:45:15Z")

</div>

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. "

---

<div class="post-metadata">

**Author:** ![kckolbe](https://avatars.discourse-cdn.com/v4/letter/k/9fc348/32.png) [@kckolbe](https://forum.choiceofgames.com/u/kckolbe)\
**Post date:** [February 21, 2024, 9:50pm UTC](https://forum.choiceofgames.com/t/help-with-generating-randomized-text-options-within-a-label-not-entire-scene/149566/2 "2024-02-21T21:50:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Loudbeat](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/loudbeat/32/115975_2.png) [@Loudbeat](https://forum.choiceofgames.com/u/Loudbeat)\
**Post date:** [February 21, 2024, 10:00pm UTC](https://forum.choiceofgames.com/t/help-with-generating-randomized-text-options-within-a-label-not-entire-scene/149566/3 "2024-02-21T22:00:01Z")

</div>

Does this work?

```choicescript
*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.

---

<div class="post-metadata">

**Author:** ![erinskye](https://avatars.discourse-cdn.com/v4/letter/e/2acd7d/32.png) [@erinskye](https://forum.choiceofgames.com/u/erinskye)\
**Post date:** [February 21, 2024, 10:16pm UTC](https://forum.choiceofgames.com/t/help-with-generating-randomized-text-options-within-a-label-not-entire-scene/149566/4 "2024-02-21T22:16:42Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Loudbeat](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/loudbeat/32/115975_2.png) [@Loudbeat](https://forum.choiceofgames.com/u/Loudbeat)\
**Post date:** [February 21, 2024, 10:20pm UTC](https://forum.choiceofgames.com/t/help-with-generating-randomized-text-options-within-a-label-not-entire-scene/149566/5 "2024-02-21T22:20:27Z")

</div>

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

You can check this post to start learning choicescript.

> [@Master List: Links for Beginners](https://forum.choiceofgames.com/t/master-list-links-for-beginners/21872):
>
> Since this gets asked a lot I thought I’d try and create a master list of links for beginners. If anyone wants to add links to the list please feel free to since I’m making this wiki format. [Start here for newcomers](https://www.choiceofgames.com/make-your-own-games/choicescript-intro/)[The Wiki](http://choicescriptdev.wikia.com)[ChoiceScript Basic Tutorial](http://choicescriptdev.wikia.com/wiki/A_Basic_Tutorial) on wiki [RETowers’ Tutorial](https://forum.choiceofgames.com/t/the-beginners-guide-to-choicescript/9866) by @RETowers[Lglasser’s Tutorial](https://forum.choiceofgames.com/t/choicescript-full-tutorial-finished/16130) by @Lglasser Dedicated ChoiceScript Development Tools You do not need to download or update ChoiceScript when using either of these tools. [Chronicler](https://forum.choiceofgames.com/t/tool-chronicler-choicescript-visual-code-editor/6811) Visual Code Editor by @Ben…

---

<div class="post-metadata">

**Author:** ![erinskye](https://avatars.discourse-cdn.com/v4/letter/e/2acd7d/32.png) [@erinskye](https://forum.choiceofgames.com/u/erinskye)\
**Post date:** [February 21, 2024, 10:43pm UTC](https://forum.choiceofgames.com/t/help-with-generating-randomized-text-options-within-a-label-not-entire-scene/149566/6 "2024-02-21T22:43:28Z")

</div>

Thank you. I’ll check this out!

---

<div class="post-metadata">

**Author:** ![fsix](https://avatars.discourse-cdn.com/v4/letter/f/c2a13f/32.png) [@fsix](https://forum.choiceofgames.com/u/fsix)\
**Post date:** [February 24, 2024, 4:58am UTC](https://forum.choiceofgames.com/t/help-with-generating-randomized-text-options-within-a-label-not-entire-scene/149566/7 "2024-02-24T04:58:26Z")

</div>

> [@erinskye](#):
>
> It goes directly into a \*choice menu after this. So is that why I’m getting this error?

That snippet will require [implicit control flow](https://choicescriptdev.fandom.com/wiki/Implicit_Control_Flow) to function correctly. I’d guess you don’t have it enabled for your script.
