Selectable_if not?


#1

I’m having trouble with figuring out how to make a selectable_if check if a bolean variable is false, not true.

The error I’m getting is: Error: prologue line 327: Couldn’t parse the line after *selectable_if: not (aloof)

My code looks like this:
choice
¨¨
selectable_if not (aloof)
¨¨¨¨#Aloof
¨¨¨¨¨¨set aloof true
¨¨¨¨¨¨
goto sheet_trait
(Okay, I give up on making it look right in here. I’m using a danish keyboard, so some things don’t translate, and I don’t know which buttons to use. The code has stars in the right places…)


#2

I think I just figured it out. I’ll check.


#3

Try putting it on the same line:

*choice
  *selectable_if (not(aloof)) #Aloof
    *set aloof true
    *goto sheet_trait

Also, mark code by hitting the </> button when writing, or using three back ticks (```) above and below it.


#4

Thanks for the reply. :smile:
That’s exactly what I just tried, and it worked.
And I will try to do that next time I ask for help with code.


#5

You can also use
*selectable_if (aloof = false) #Aloof

This may be preferable based on your love of brackets or not.


#6

It took me an embarrassingly long time to realize that I was skipping a necessary parenthesis when I tried to do this, i.e. that

*selectable_if not(variable)
won’t work;

*selectable_if (not(variable))
will.


#7

*selectable_if randomvar #Option
won’t also work. Won’t pass randomtest :expressionless:


#8

I… don’t know what you’re saying.


#9

Is that a boolean test to check if a variable named randomvar returns a value of true ? I think it needs to be *selectable_if (randomvar) #option in a case like that.


#10

Yea, it is a boolean variable :sweat_smile:
Just the opposite of @Havenstone’s case.

I’m not sure with other types of variable, tho. I just assumed that all of them require parentheses.


#11

“The condition itself must always be placed within parentheses (brackets).”


#12

The basic code for a Boolean is:

*if variable = true
*if variable = false

These can also be written as:
*if (variable)
*if (not (variable))

I tend to use the second for true and the first for everything else, but these are interchangeable.


#13

Outside of #options, it’s also possible to check *if foo without parentheses. Parentheses are only mandated in the case of *selectable_if because there needs to be an end to the equation before the actual #option.