# Join Commands: \*if and \*selectable\_if and \*allow\_reuse

**URL:** <https://forum.choiceofgames.com/t/join-commands-if-and-selectable-if-and-allow-reuse/675>\
**Category:** ChoiceScript Help\
**Created:** [August 10, 2012, 6:08pm UTC](https://forum.choiceofgames.com/t/join-commands-if-and-selectable-if-and-allow-reuse/675 "2012-08-10T18:08:30Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lucid](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/lucid/32/39775_2.png) [@Lucid](https://forum.choiceofgames.com/u/Lucid)\
**Post date:** [August 10, 2012, 6:08pm UTC](https://forum.choiceofgames.com/t/join-commands-if-and-selectable-if-and-allow-reuse/675/1 "2012-08-10T18:08:30Z")

</div>

Or: \*hide\_reuse and \*if

Also, does \*if have to use a \*goto ?

For example,

```
*if (Raining)
     It's raining!

```

Instead of:

```
*if (Raining)
    It's raining!
    *goto nextpart

*label nextpart

```

* * *

Edit from March, 2020. This is the correct format:

```
*if (this_thing)
	*allow_reuse *selectable_if (that_thing) #Choose something.
		The choice occurs.
		*goto the_next_part

```

---

<div class="post-metadata">

**Author:** ![JimD](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/jimd/32/21672_2.png) [@JimD](https://forum.choiceofgames.com/u/JimD)\
**Post date:** [August 10, 2012, 6:33pm UTC](https://forum.choiceofgames.com/t/join-commands-if-and-selectable-if-and-allow-reuse/675/2 "2012-08-10T18:33:00Z")

</div>

you can use \*commands if on separate lines

\*if (holding\_pistol)  
\*hide\_reuse #Shoot him in the face

\*if does not have to use a \*goto if you just want to include some conditional phrase or check.

---

<div class="post-metadata">

**Author:** ![Lucid](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/lucid/32/39775_2.png) [@Lucid](https://forum.choiceofgames.com/u/Lucid)\
**Post date:** [August 11, 2012, 2:09pm UTC](https://forum.choiceofgames.com/t/join-commands-if-and-selectable-if-and-allow-reuse/675/3 "2012-08-11T14:09:40Z")

</div>

Thanks, that’s handy.

I guess my \*if problem happened when I followed up with an \*else

Eg)  
\*If (raining)  
It’s raining.  
\*else  
It’s not raining.

That fell out of the if and into an else, giving me an error.

---

<div class="post-metadata">

**Author:** ![Havenstone](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/havenstone/32/198451_2.png) [@Havenstone](https://forum.choiceofgames.com/u/Havenstone)\
**Post date:** [August 11, 2012, 3:06pm UTC](https://forum.choiceofgames.com/t/join-commands-if-and-selectable-if-and-allow-reuse/675/4 "2012-08-11T15:06:27Z")

</div>

@Lucid - yep, that’ll do it.

---

<div class="post-metadata">

**Author:** ![christoph](https://avatars.discourse-cdn.com/v4/letter/c/eb8c5e/32.png) [@christoph](https://forum.choiceofgames.com/u/christoph)\
**Post date:** [August 23, 2012, 11:55am UTC](https://forum.choiceofgames.com/t/join-commands-if-and-selectable-if-and-allow-reuse/675/5 "2012-08-23T11:55:13Z")

</div>

ran into a little trouble with this section, I am creating inventory as follows and getting error must have \*goto or \*finish maybe missing something here but I believe I have that…

ie:  
Not knowing how long the virus will last, nor what is really happening outside what will you take? (you can only take 6 items

choose carefully)  
\*hide\_reuse  
\*label start  
\*choice  
#food and water(10 lbs)  
\*goto start  
\*selectable\_if (military\_officer)  
#MRE’s and Canteen  
\*goto start  
#Flashlight(4 lbs)  
\*goto start  
\*selectable\_if (paramedic)  
#Emergancy Kit(7 lbs)  
\*goto start  
#fire starters(2 lbs)  
\*goto start  
\*selectable\_if (camping\_and\_hiking)  
#Survival back packs and gear(20 lbs)  
\*goto start  
\*selectable\_if (police\_officer)  
#riot gear(15 lbs)  
\*goto start  
\*selectable\_if (camping\_and\_hiking)  
#rope(5 lbs)  
\*goto start  
\*selectable\_if (hunting)  
#hunting knife(7 lbs)  
\*goto start  
#M9 Pistol(6 lbs)  
\*goto start  
\*selectable\_if (millitary\_officer)  
#M16 rifle(8 lbs)  
\*goto start  
#Winchester 800 shotgun(8 lbs)  
\*goto start  
#extra ammunition(15 lbs)  
\*goto start  
#night vision goggles(3 lbs)  
\*goto start  
#small first-aid kit(3 lbs)  
\*goto start  
#rain gear(3 lbs)  
\*goto start  
#emergancy radio(5 lbs)  
\*goto start  
#extra batteries(2 lbs)  
\*goto start  
#multi-purpose tool(2 lbs)  
\*goto start  
\*selectable\_if (gardening)  
#garden supplies to grow food(12 lbs)  
\*goto start  
#two way radios(6 lbs)  
\*goto start  
\*selectable\_if (woodworking)  
#building supplies(20 lbs)  
\*goto start  
#emergancy small generator(15 lbs)  
\*goto start  
#Done  
\*finish

---

<div class="post-metadata">

**Author:** ![Vendetta](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/vendetta/32/533_2.png) [@Vendetta](https://forum.choiceofgames.com/u/Vendetta)\
**Post date:** [August 23, 2012, 1:10pm UTC](https://forum.choiceofgames.com/t/join-commands-if-and-selectable-if-and-allow-reuse/675/6 "2012-08-23T13:10:21Z")

</div>

It might have something to do with that \*hide\_reuse near the beginning, which is intended to be used _within_ a \*choice list in much the same way as \*selectable\_if, e.g.

\*hide\_reuse #Food and water (10lbs)

Unless of course you do want _all_ the #options to be \*hide\_reuse, in which case you do want to leave that as it is.

Note also that \*selectable\_if should itself generally be used as follows (i.e. not a separate line):

\*selectable\_if (military\_officer) #MREs and Canteen

---

<div class="post-metadata">

**Author:** ![christoph](https://avatars.discourse-cdn.com/v4/letter/c/eb8c5e/32.png) [@christoph](https://forum.choiceofgames.com/u/christoph)\
**Post date:** [August 23, 2012, 1:41pm UTC](https://forum.choiceofgames.com/t/join-commands-if-and-selectable-if-and-allow-reuse/675/7 "2012-08-23T13:41:00Z")

</div>

I do want it to be all choices hide\_reuse, but as for the selectable\_if I have tried on the same line and still getting the error

---

<div class="post-metadata">

**Author:** ![Vendetta](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/vendetta/32/533_2.png) [@Vendetta](https://forum.choiceofgames.com/u/Vendetta)\
**Post date:** [August 23, 2012, 4:44pm UTC](https://forum.choiceofgames.com/t/join-commands-if-and-selectable-if-and-allow-reuse/675/8 "2012-08-23T16:44:12Z")

</div>

Hmm. Best would be to post your code again but put \< pre\> before it and \< /pre\> after it (without those spaces), which will retain the indentation in the forum. It should then be much easier to spot what’s causing the problem.

---

<div class="post-metadata">

**Author:** ![christoph](https://avatars.discourse-cdn.com/v4/letter/c/eb8c5e/32.png) [@christoph](https://forum.choiceofgames.com/u/christoph)\
**Post date:** [August 24, 2012, 10:43am UTC](https://forum.choiceofgames.com/t/join-commands-if-and-selectable-if-and-allow-reuse/675/9 "2012-08-24T10:43:02Z")

</div>

```

Not knowing how long the virus will last, nor what is really happening outside what will you take? (you can only take 6 items choose carefully)
\*hide_reuse
\*label start
\*choice
  #food and water(10 lbs)
    \*goto start
  \*selectable_if (military_officer) 
  #MRE's and Canteen
    \*goto start
  #Flashlight(4 lbs)
    \*goto start
  \*selectable_if (paramedic) 
  #Emergancy Kit(7 lbs)
    \*goto start
  #fire starters(2 lbs)
    \*goto start
  \*selectable_if (camping_and_hiking) 
  #Survival back packs and gear(20 lbs)
    \*goto start
  \*selectable_if (police_officer) 
  #riot gear(15 lbs)
    \*goto start
  \*selectable_if (camping_and_hiking) 
  #rope(5 lbs)
    \*goto start
  \*selectable_if (hunting) 
  #hunting knife(7 lbs) 
    \*goto start
  #M9 Pistol(6 lbs)
    \*goto start
  \*selectable_if (millitary_officer) 
  #M16 rifle(8 lbs)
    \*goto start
  #Winchester 800 shotgun(8 lbs)
    \*goto start
  #extra ammunition(15 lbs)
    \*goto start
  #night vision goggles(3 lbs)
    \*goto start
  #small first-aid kit(3 lbs)
    \*goto start
  #rain gear(3 lbs)
    \*goto start
  #emergancy radio(5 lbs)
    \*goto start
  #extra batteries(2 lbs)
    \*goto start
  #multi-purpose tool(2 lbs)
    \*goto start
  \*selectable_if (gardening) 
  #garden supplies to grow food(12 lbs)
    \*goto start
  #two way radios(6 lbs)
    \*goto start
  \*selectable_if (woodworking) 
  #building supplies(20 lbs)
    \*goto start
  #emergancy small generator(15 lbs)
    \*goto start
  #Done
    \*finish
< /pre>
```

---

<div class="post-metadata">

**Author:** ![Vendetta](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/vendetta/32/533_2.png) [@Vendetta](https://forum.choiceofgames.com/u/Vendetta)\
**Post date:** [August 24, 2012, 11:20am UTC](https://forum.choiceofgames.com/t/join-commands-if-and-selectable-if-and-allow-reuse/675/10 "2012-08-24T11:20:43Z")

</div>

Can’t spot anything there other than the fact that those #options using \*selectable\_if are not on the same line. You should correct those, if only because it makes bug-hunting something like this easier (i.e. easier to make sure you have all the \*gotos in the right place).

There’s also an instance where you spell “millitary\_officer” like so, and another case where you spell it correctly with a single L. One of those must be different to the spelling used in mygame.js so will need correcting.

---

<div class="post-metadata">

**Author:** ![christoph](https://avatars.discourse-cdn.com/v4/letter/c/eb8c5e/32.png) [@christoph](https://forum.choiceofgames.com/u/christoph)\
**Post date:** [August 24, 2012, 11:32am UTC](https://forum.choiceofgames.com/t/join-commands-if-and-selectable-if-and-allow-reuse/675/11 "2012-08-24T11:32:10Z")

</div>

I have actually added them all on the same line after posting it here but I still get the error

---

<div class="post-metadata">

**Author:** ![Vendetta](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/vendetta/32/533_2.png) [@Vendetta](https://forum.choiceofgames.com/u/Vendetta)\
**Post date:** [August 24, 2012, 12:02pm UTC](https://forum.choiceofgames.com/t/join-commands-if-and-selectable-if-and-allow-reuse/675/12 "2012-08-24T12:02:08Z")

</div>

Cool, heading in the right direction. Post it again please. And is it still the same error you mentioned previously?

Just a thought as well, if you’re deleting any lines from your actual script before posting it, I’d recommend not doing so. It’s hard to help if we can’t see the full picture.

---

<div class="post-metadata">

**Author:** ![AlexCosarca](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/alexcosarca/32/68977_2.png) [@AlexCosarca](https://forum.choiceofgames.com/u/AlexCosarca)\
**Post date:** [August 24, 2012, 12:44pm UTC](https://forum.choiceofgames.com/t/join-commands-if-and-selectable-if-and-allow-reuse/675/13 "2012-08-24T12:44:07Z")

</div>

I’ve noticed this section:

```

*choice
    *selectable_if (military_officer) 
        #MRE's and Canteen
            *goto start

```

Try doing as I said above with it. and about the choices that use no \*if or \*selectable\_if’s, put them on the same line with the \*selectable\_if’s and the \*if’s, not on the same line with the choices; do this:

```

*choice
    *selectable_if (military_officer) 
        #MRE's and Canteen
            *goto start
    #Choice2
        *goto start

```

Instead of this:

```

*choice
    *selectable_if (military_officer) 
        #MRE's and Canteen
            *goto start
        #Choice2
            *goto start

```

That’s the only thing I can spot wrong at a first view.

---

<div class="post-metadata">

**Author:** ![Vendetta](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/vendetta/32/533_2.png) [@Vendetta](https://forum.choiceofgames.com/u/Vendetta)\
**Post date:** [August 24, 2012, 12:53pm UTC](https://forum.choiceofgames.com/t/join-commands-if-and-selectable-if-and-allow-reuse/675/14 "2012-08-24T12:53:40Z")

</div>

Unless they’ve quite recently changed how CS handles \*selectable\_if, that will probably result in a parsing error.

---

<div class="post-metadata">

**Author:** ![AlexCosarca](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/alexcosarca/32/68977_2.png) [@AlexCosarca](https://forum.choiceofgames.com/u/AlexCosarca)\
**Post date:** [August 24, 2012, 2:25pm UTC](https://forum.choiceofgames.com/t/join-commands-if-and-selectable-if-and-allow-reuse/675/15 "2012-08-24T14:25:33Z")

</div>

@Vendetta, Well, it works with the \*if commands, and I never used the \*selectable\_if (mainly because of the errors encountered with it) so I don’t really know.

Anyways, why don’t you change the \*selectable\_ifs into \*ifs, which would fix it? Just a suggestion…

---

<div class="post-metadata">

**Author:** ![Vendetta](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/vendetta/32/533_2.png) [@Vendetta](https://forum.choiceofgames.com/u/Vendetta)\
**Post date:** [August 24, 2012, 5:30pm UTC](https://forum.choiceofgames.com/t/join-commands-if-and-selectable-if-and-allow-reuse/675/16 "2012-08-24T17:30:24Z")

</div>

Yep, you’re correct on that score–when used within a \*choice statement the _ordinary_ \*if condition(s) should indeed be placed on their own line, followed on the next line (and indented again accordingly) by any ordinary #option, \*hide\_reuse _or_ \*selectable\_if. This makes the \*choice statement highly flexible, by allowing a variety of \*if conditions to be pre-applied to _any_ of the three types of options.

However, when \*selectable\_if is the only condition needed (as in this case), then it should simply be written as (and all on one line):

\*selectable\_if (military\_officer) #MRE’s and Canteen

Concerning your last comment; it’s a fair question so I’ll answer in full for any future readers wondering the same thing!

He really doesn’t want to change his \*selectable\_ifs to ordinary \*ifs in this case. Not only is it unnecessary to do so (he just needs to follow the example above), he has also chosen the correct option type for what he wants to achieve here, which is to “gray out” a \*selectable option if the player does not qualify. By this means the player knows that when they play again and choose different options at an earlier stage, different options would then become available at this point (e.g. Military Officers get a canteen). He doesn’t want to _hide_ the information in this case (which is what an ordinary \*if would do) as it encourages replays to try those unselectable options.

---

<div class="post-metadata">

**Author:** ![AlexCosarca](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/alexcosarca/32/68977_2.png) [@AlexCosarca](https://forum.choiceofgames.com/u/AlexCosarca)\
**Post date:** [August 24, 2012, 6:19pm UTC](https://forum.choiceofgames.com/t/join-commands-if-and-selectable-if-and-allow-reuse/675/17 "2012-08-24T18:19:08Z")

</div>

@Vendetta, I get it now. Well, in that case, \*selectable\_if shouldn’t have a problem when placed the way you said it should be placed…

---

<div class="post-metadata">

**Author:** ![Vendetta](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/vendetta/32/533_2.png) [@Vendetta](https://forum.choiceofgames.com/u/Vendetta)\
**Post date:** [August 24, 2012, 7:22pm UTC](https://forum.choiceofgames.com/t/join-commands-if-and-selectable-if-and-allow-reuse/675/18 "2012-08-24T19:22:15Z")

</div>

To help explain what I meant in my previous post, I’ve knocked up the following example to demonstrate how the the different #options of a \*choice statement should be laid out. Bear in mind that this is just a bit of nonsense as an example of the different things you can do, different ways you can use these elements together, and some things to bear in mind when doing so–such as the required indentation for each style, and where & when you need double parentheses, etc.

I’ve included the \*temps so you can just copy & paste this into a current project and play around with it by changing the values, just to see what effect it has on the options displayed.

```

*temp shadowwalk
*set shadowwalk 30
*temp infravision
*set infravision 30
*temp lit_torch_held
*set lit_torch_held false
*temp agility
*set agility 50

*label throne_room
*choice
    #Cross the throne room and exit through the doorway at the far side
        *if shadowwalk > 20
            You tip-toe across the throne room and head into a damp passageway.
            *goto damp_passage
        *else
            You clumsily trip over the dragon's tail and promptly get eaten.
            *ending
    *if (shadowwalk > 30) and ((infravision > 30) or (lit_torch_held = true))
        *hide_reuse #Search every nook and cranny of the throne room.
            You search every nook and cranny . . . pointlessly.
            *goto throne_room
    *if (shadowwalk < 31) and ((infravision < 31) and (lit_torch_held = false))
        #Search the throne room, avoiding the sleeping dragon.
            You trip over the dragon's tail. She awakens and gobbles you up . . . Burp!
            *ending
    *selectable_if ((agility > 50) and (shadowwalk < 31)) #Leap for the balcony.
        You reach the balcony, grab the treasure, and leave via an open window.
        *goto castle_grounds
    *if shadowwalk > 30
        *selectable_if (agility < 50) #Quietly leap up to the crumbling balcony
            You fail to reach the balcony but land softly, without awakening the dragon.
            *goto throne_room
    *hide_reuse #Dance a jig around the sleeping dragon . . . quietly!
        You (somewhat pointlessly) dance a silent jig around the dragon. Zzzzzzz.
        *goto throne_room
    #Hack the head off the slumbering dragon.
        Nice try . . . You succeed only in annoying her. Charred adventurer! Yummy!
        *ending

*label damp_passage
Damp passageway blah blah blah
*ending

*label castle_grounds
Castle grounds blah blah blah
*ending

```

---

<div class="post-metadata">

**Author:** ![JimD](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/jimd/32/21672_2.png) [@JimD](https://forum.choiceofgames.com/u/JimD)\
**Post date:** [August 24, 2012, 8:32pm UTC](https://forum.choiceofgames.com/t/join-commands-if-and-selectable-if-and-allow-reuse/675/19 "2012-08-24T20:32:44Z")

</div>

One thing, if you are using the above as an inventory, you need to change the item variable to true in each block.

```

\*selectable_if (police_officer) #riot gear(15 lbs)
  \*set riot_gear true
  \*goto start
\*selectable_if (camping_and_hiking) #rope(5 lbs)
  \*set rope true
  \*goto start 

etc.
```

---

<div class="post-metadata">

**Author:** ![P\_Tigras](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/p_tigras/32/626_2.png) [@P\_Tigras](https://forum.choiceofgames.com/u/P_Tigras)\
**Post date:** [August 24, 2012, 9:44pm UTC](https://forum.choiceofgames.com/t/join-commands-if-and-selectable-if-and-allow-reuse/675/20 "2012-08-24T21:44:17Z")

</div>

@Cristoph, I’ve tested your code, and it works just fine with the following edits:

1. all referenced variables are created and given initial values.
2. all \*selectable\_if’s and #SelectableOptions are placed on the same line.
3. millitary\_officer is changed to military\_officer

My version of firefox errors out with “Couldn’t parse the line after \*selectable\_if: (var\_name)” where var name is something like “military\_officer” whenever \*selectable\_if and #SelectableOptions are on separate lines. That’s the only serious issue I noticed.

Of course to really make it useful you’ll have to set item variables to true as @JimD has mentioned, and add some additional logic that will exit the loop once you equip 6 items. Currently it doesn’t end until the player selects “Done”.

[Next page](https://forum.choiceofgames.com/t/join-commands-if-and-selectable-if-and-allow-reuse/675.md?page=2)
