Shattered Stars 11-99!

Good evening. I have a code question that I cannot seem to find on the wiki.

There’s some dialogue in the game I’m writing that, in short, should not be selectable IF a certain criteria are met rather than the criteria not being met.

*selectable_if doesn’t work for this because it is a numerical value (I’m still learning how to use… booleans?) rather than a text based value.

So what is the ChoiceScript version of *selectable_if_not?

1 Like

Could you show us the code you’re trying to use and/or explain the criteria?
I don’t think there’s a selectable_if_not functionality, but it’s usually not too hard to make some workaround for whatever you’re trying to do.

 #I brought fried porkchops! Synthetic versions of porkchops at least.  
  *set Authoritarian -2
  *goto Porkchops
  *finish

This is the choice being made in the game in question. Essentially, earlier in the game, the choice of religion is possible. Since Islamic religions do not eat pork, I’d like to make this option incapable of being selected if the player character is a Muslim to avoid accidental selection.

You said the religion variable is numeric? So you have something like *set religion 2 and the 2 represents Islam?

I think it’s as simple as doing:
*selectable_if (religion !=2) #choice text here

!= translates to “not equal.” So the choice will be selectable if the religion stat is set to any other value.

2 Likes

Correct. Islam sets the number as I believe 3 or 1. I’d have to check my notes.

I’ll try this code out and get back to you. I’m sure other people would like to see this in case they have the same question though it could take a moment as I’m writing a large number of scenes right now.

*choice
	*selectable_if (not(var)) #Choice

This should work, but yup, you could also use != instead.

2 Likes

*label Faith

And are you a ${gender} of faith?

*choice
#I adhere to the Catholic faith.
*set Religion 0
*goto ShipName
*finish
#I am a practicing Muslim.
*set Religion 1
*goto ShipName
*finish
#I am a Protestant Christian.
*set Religion 2
*goto ShipName
*finish
#I do not have any sort of faith.
*set Religion 3
*goto ShipName
*finish
#I am a Jew.
*set Religion 4
*goto ShipName
*finish

This is the code for the dialogue option when selecting your religion.

Would the code you propose be used as this then:

*selectable_if (not(Religion = 1)) #choice

Yes. Sorry, I should’ve used your example.

No problem friend though I just realized that Jews actually can’t eat pork either because it is not considered Kosher.

`````*goto Porkchops
`````*finish

This is giving me an error message. "Expected close parenthesis".

Ack! The forum ate my code!

 *selectable_if ((not(Religion = 1) or (Religion = 4)) #I brought fried porkchops! Synthetic versions of porkchops at least.  
  *set Authoritarian -2
  *goto Porkchops
  *finish

If I understand this correctly, you shouldn’t be able to pick the choice if Religion is 1 OR 4, right?

*choice
	*selectable_if ((not(Religion = 1)) and (not(Religion = 4))) #I brought fried porkchops! Synthetic versions of porkchops at least. 

I just tested this, so it should work. Note that I put an “and” instead of an “or” between the two variables, because both conditions must be true.

The parentheses get tricky with two or more variables, so personally I’d just use != like so:

*choice
	*selectable_if ((Religion != 1) and (Religion != 4)) #I brought fried porkchops! Synthetic versions of porkchops at least. 
3 Likes

I appreciate the assistance. Anything I can do in return?

2 Likes

Nah, it’s fine. Good luck with your project!

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.