Need a little help :)

Hey guys, long time lurker here. I’ve just started writing a story about three days ago… and I wanted to throw some of the prologue into Choice Script.

Since I have 0 programming experience, this is starting to look like a daunting project. Nevertheless, I really love some of the content here (and I would like to contribute to my own). Having said that, I’ve already hit a snag.

1st question: How does one make a loop?

For instance, I have a section like this…

words words words words, stuff happens, more words.
word words more words.

[Option A]
[Option B]

It’s sort of a fake choice, in that I want the player to see both options. For example, I want him to click on option A, then be re-routed back to option B —> BUT, once he’s re-routed, I’d like option A to be greyed out and un-clickable.

Thanks in advance for any help. I image this may become a thread of similar questions, but the community here has always seemed welcoming and generally helpful. So cheers to that!

Sounds like you want to use *selectable_if

The *hide_reuse command only shows the choices that you haven’t selected yet, and once you choose something it then the option disappears entirely. *selectable_if, on the other hand, shadows the choice out if you can’t choose it.

So for what you want to do, I’d have two temp variables tied to the *selectable_if so that it activates once you go back to the *choice again. So it would look like this:

*temp option_A false
*temp option_B false
*label firstchoice
Pick any option available.
*choice
  *selectable_if (option_A = false) #Option A
    You've chosen Option A
    *set option_A true
    *if option_B = false
      *goto firstchoice
    *else
      *goto nextscene
  *selectable_if (option_B = false) #Option B
    You've chosen Option B
    *set option_B true
    *if option_A = false
      *goto firstchoice
    *else
      *goto nextscene

Usually, I’d recommend against loops with the same choices (as it makes the game feel much more linear and less like the player has any real options).

That said the simple way is with *hide_reuse.

1 Like

Hello. Check out the wiki and http://www.choiceofbox.com and the daunting task won’t be so daunting anymore! In order to get a loop, you need some sort of counter that keeps tracks of how many choices you’ve selected. Here’s an example;

*temp counter 0
*label top
What do you choose?

*choice
  *hide_reuse #Option A
    You have selected A
    *page_break
    *set counter +1
    *if (counter >= 2)
      *goto end
    *goto top
  *hide_reuse #Option B
    You have selected B
    *page_break
    *set counter +1
    *if (counter >= 2)
      *goto end
    *goto top

*label end
The End

Unless you’ve selected 2 or more choices, you’ll end up back at *label top. Oh and don’t be fooled by the names, choice and fake_choice, the only difference is how it reads, you could do the same thing with a fake choice, just a little differently;

*temp counter 0
*label top
What do you choose?

*fake_choice
  *hide_reuse #Option A
    You have selected A
    *page_break
    *set counter +1
    *if (counter < 2)
      *goto top
  *hide_reuse #Option B
    You have selected B
    *page_break
    *set counter +1
    *if (counter < 2)
      *goto top

*label end
The End

It will have the same result as the example above. And in the time it took to type this, it’s probably already been said already hahaha.

Brilliant! But its seems a bit more complicated then the hide_reuse command. Still, I can already think of a situation where this would be preferable… especially considering character stat checks (somewhere down the road).

Thanks man.

For my first work I’m planning on keeping it a little more linear… both for the sake of story and my lack of coding experience. That said, it won’t be entirely “on rails”. And I don’t plan on using the loop for anything to important (i.e. background info).

Thanks for the warning though!

Wow! A million thanks for this. I did already check out the Wiki. And I have been slowly digesting everything. But some of the description are a little rough for me. It even has a page on looping there, but I couldn’t really understand the examples.

Yours makes much more sense to me. I’ll start hammering through this tomorrow then. It’s quite late here and my brain is sufficiently fried.