You should consider joining our Discord to ask for support.

We created a support channel using the new Discord Forum feature!

You can also visit our new website, it has a help section in English and French

0 like 0 dislike
289 views
in Script help by (120 points)
How do you make certain choices show up in a "choices selection" depending on whether or not certain conditions are met? Example: There exists items A, B, C. If the player has items A and B, then during the "choices selection," you are able to select options A or B. However, if the player obtains item C, there now appears 3 options (A, B, C).

1 Answer

0 like 0 dislike
by (28.0k points)

Ok, so what you tried with the array was correct, the only detail is that the result variable contains a value between 1 & n options.

Meaning that if you pick the 4th option, the result variable is 4.
 

So the ruby script would be:

@choices = []
@choices << 'Option A' if condition_a
@choices << 'Option B' if condition_b
# ...

Once you've run this snippet, you can create the first condition that will check you can actually make a choice:

!@choices.empty?

And in this condition you'll enter:

Script: choice(201, -1, *@choices)
Message: What do you choose

After that you can either do a series of script condition with:

@choices[gv[201] - 1] == 'Some string'

Or do something more clever if you're doing some generic stuff like giving an item or something that can be serialized with a Hash map. For example:

Script: 
  @choices = ['Pokéball']
  @choices << 'Great Ball' if gv[36] > 2
  @choices << 'Ultra Ball' if gv[36] > 4
Script: choice(201, -1, *@choices)
Message: What do you want to get?
Script:
  item_id = { 'Pokéball' => 4, 'Great Ball' => 3, 'Ultra Ball' => 2 }[@choices[gv[201] - 1]
  give_item(item_id, 5)

This will give 5 of the chosen item :)

...