Neither true nor false


#1

So, I have two variables.
sword, which is boolean. You have one or your don’t, true or false. Not a *temp, it’s defined as false in my mygame.js
and
swordplay, which is a number

I randomly get the error “neither true no false” on this line of a *choice statement.:
*if (sword) #Swing the sword.

It treats it like a number, but it really is a true or false boolean. I mention the swordplay variable, wondering if it’s somehow confusing the two.

It works most of the time, but sometimes doesn’t.

I know I can rename the sword boolean variable, if that’s the error, but… is that the error?


#2

Wouldn’t it be this?

*selectable_if (sword = true) #Swing the sword


#3

Only if you want the option as greyed out. I don’t want to show it at all.

I shouldn’t have to have the =true part either, although I wonder if that would make it happy.


#4

Oh, are booleans true by default in CS?


#5

No, @Proff you define whether a Boolean starts off as true or false in mygame.js


#6

*if works best on its own line I’ve found, so try
*if (sword)
#Swing the sword


#7

I can attest to the merits of JimD’s method.

*if (sword)
    #Swing the sword.

That also frees up the ability to do some

*if (sword)
    *hide_reuse #Swing the sword.

or

*if (sword)
    *selectable_if (swordplay > 30) #Swing the sword.

in case anyone likes complicating their choices as much as I do. :slight_smile:


#8

@JimD
Thanks, I’ll try it. It’s strange to have an error that doesn’t consistently pop up.


#9

@CS_Closet
Oh yes, I have some wickedly embedded choices too. :slight_smile: