Neither true nor false


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
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?


Wouldn’t it be this?

*selectable_if (sword = true) #Swing the sword


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.


Oh, are booleans true by default in CS?


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


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


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.


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

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


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


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