If and selectable_if?


#1

So I’m fairly certain this is more a variable issue but I can’t get my boxes to appear grey or not when I use “if” I assumed you needed to create the variable like *create President followed by *if (President) #Abuse power. Much like the tutorial showed but what if I wanted your decision to hinge on your gender? Would it be *create gender
"Oh I’m totally a guy" *set gender male""
You’re walking by the barflys when one gives a wolf whistle aimed at you.
*If (male) #Punch him in the face. Is this right?


#2

Not exactly, both for a common sense reason and for a programming logic reason.

On a common sense level, the propensity to resolve interpersonal conflicts with violence isn’t actually based on what organs people assume grew between your legs, or even what organs actually grew between your legs. So in this specific example, a personality trait like *if (anger > 60) #Punch him in the face. works far more effectively than any possible gender option.

On a programming level, the style of *if check you mention only works for true-false variables and doesn’t work for variables that save a string of numbers or letters.

If your gender variable at the top of the startup file looked like *create female true, and your gender selection choice looked something like:

*fake_choice
    #I'm a woman.
        *set female true
    #I'm a man.
        *set female false

…Then in that case, you’d be using a boolean (true-false) variable, and the correct way to check it would be exactly as you guessed. *if (female) or *if not(female).

However, that’s not the variable type you mentioned using.

You mentioned using a string variable to save a series of letters. Specifically, *set gender "female" and *set gender "male".

When using *if to check a string variable, you do it like this:

*fake_choice
    *if (gender = "female") #I'm going to visit the ladies' room.
    *if (gender = "male") #I'm going to visit the men's room.

Final note: when using *if like this, the options you can’t choose are completely hidden from view. Vanished. Poof, gone. If you want those options to be visible but not selectable (to be greyed-out,) use *selectable_if instead.

Like so: *selectable_if (anger > 60) #Punch him in the face.


#3

Admittedly not my best analagy.


#4

Okay nope I lied to placate you, it’s still not working can I post some screen shots and you tell me why it won’t work? I tried Boolean and… the other one and can get neither to work


#5





#6

Try indenting the *if statement there so it’s in like with the #“I dont know…”

. As it is, it’s not part of the *choice


#7

Just a short FYI.
You can click the </> button on the comment toolbar to enable Preformatted text tag.

This way, you can copy-paste your code to the forum quickly and nicely.


#8

Right should have thought about that thank you


#9

Btw, what’s your problem again? The #choice option box doesn’t appear as greyed out?

Instead of *if, try using *selectable_if


#10

You shouldn’t have apostrophes in a label (*label sure_I'm_sure). Try *label sure_Im_sure instead.