Selectable_if and temp command issue


#1

I’m just starting to try out choicescript, and I’m running into an issue with some of the beginning of the “test game” I’m trying out. I wanted to make a scene where the user chooses three skills out of six different options. The problem is that I can’t seem to figure out how to stop the player from selecting skills once they’ve reached three.
Here’s my code for the scene:

*label Magic
*hide_reuse
*temp options 0
Now every magician has some sort of raw, natural talent on them. Something that they can understand and perform better than any other kind of magic. What is your strength? (Choose 3)
*choice
*selectable_if (options < 3) #Fire Magic
*set Fire_Magic +10
*set options +1
*goto Magic
*selectable_if (options < 3) #Ice Magic
*set Ice_Magic +10
*set options +1
*goto Magic
*selectable_if (options < 3) #Wind Magic
*set Wind_Magic +10
*set options +1
*goto Magic
*selectable_if (options < 3) #Lightning Magic
*set Lightning_Magic +10
*set options +1
*goto Magic
*selectable_if (options < 3) #Telekinesis
*set Telekinesis +10
*set options +1
*goto Magic
*selectable_if (options < 3) #Necromancy
*set Necromancy +10
*set options +1
*goto Magic
#Done
*finish

I’m not sure if there’s a more efficient way of doing this, but I created a temporary variable (options) in order to count how many choices had been made, and then just put the selectable_if command depending on the value of options.

I’ve tested out a few things, and I believe the fault lies in the relationship between the temp variable options and the selectable_if command I have. I think that I’m somehow typing the (options < 3) part wrong, but if so I’m not sure how to do it “right.”

(edit: for some reason my indenting isn’t transferring well through the post. Trust me my indenting is fine I believe, and it shouldn’t be the issue)


#2

Your *temp needs to be above the *label, or it will be set to 0 every time you repeat the choice.


#3

I tried that as well, but I get an error saying, “Non-existent variable ‘options,’” in the scene right before this one, I think because it is temporary only in the scene it is placed in.

If that’s true, this method probably just leaves me to a dead end, correct?


#4

There is no need for a *hide_choice at the start, these are used for *choice options.

The *temp needs to be outside of this loop otherwise it will be reset every time to 0. You can have it at the beginning of the file you are now, right at the top. Once the file is loaded, the *temp will be created and will be usable for as long as you are in this scene file.


#5

Yes, it has to be in the same scene file. And the game has to read it.

Do you get to *label Magic from a *goto or *gosub originally? or does it just go there from whatever comes before?

I am pretty sure *hide_reuse can be used this way too. Other people have mentioned doing it.


#6

Interesting, I thought it was only for *choice options. I’ll have to give that a try to see what exactly it does outside of choices.


#7

It stops reuse for the entire scene, or until using *allow_reuse.

@Idriel One way to do this would be to use two different labels. One to *goto from other parts, and one below the *temp, that you can *goto from the choices.

bla bla bla
*goto magic

*label magic
*hide_reuse
*temp options 0
*label magic2
bla bla
*choice
#blabla
*goto magic2


#8

Thanks, that’s pretty useful. Learn something new every day. Will try it out when I have the chance.


#9

Oh okay! I’ll try that out, thanks a ton


#10

After the returning label but before presenting the choices, I recommend having

*if (options => 3)
  *goto next_part_of_the_game

instead of a “done” choice at the bottom. It feels more natural when you play.