Boolean operations in Bitsy

I came across this post by Eevee when I was trying to figure out if there is a way to add booleans to bitsy dialog without resorting to messing with the code. Turns out it is possible with a little maths. This post is something of a reference for myself as well as you, the reader.

In bitsy you can create booleans with variables. Lets call our variables:

  • hasApples
  • hasOranges

At the start of the game, hasApples and hasOranges should be set to zero as I have neither.

  • hasApples:0
  • hasOranges:0

As I play, I can change these variables in the dialog using curly brackets like so, {hasApples = 1}, {hasOranges = 1}.

If I want to check in a conditional dialog if I have both apples and oranges, I can do this like so using the “custom” field on the dialog box.

dialog

  • hasApples * hasOranges == 1
    • This checks if I have apples and oranges, by seeing if both apples and oranges have a value of 1. If either has a value of 0, the test will fail.

This obviously means you can check the opposite.

  • hasApples * hasOranges == 0
    • This checks if I don’t have either apples or oranges. It will also pass if I have neither apples or oranges.

If you want to check if you have apples or oranges, you can do this:

  • hasApples + hasOranges >=1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s