Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs

Bitsy Game Maker

Make little games, worlds, and stories! · By Adam Le Doux

2 variables in one condition?

A topic by eminidhogg created Feb 08, 2018 Views: 261 Replies: 2
Viewing posts 1 to 2
(+1)

Hi,  is there anyway to combine 2 variables using and or && ?? . I tried this for example, and didn't work     - a == 1 && g >= 10 ?  

(+1)

Apparently you CAN do nested conditionals, which could get awkward if you want, say 3 variables. But it's better than nothing.

{
  - variable1 == 1 ?
    {
      - variable2 == 1 ?
        Variable1 AND Variable2 both equal 1!
      - else ?
        Variable1 equals 1 but Variable2 does not.
    }
  - else ?
    Variable1 does not equal 1!
}
(4 edits)

Thank you, ayolland! I used this in my game to begin making a cooking system, and you don't need to edit the .html file of the game or anything, you can do it right in the normal dialogue editor. Here's what I did, for any other newbies who want to know:

1. Have two different possible food items (I have berries and fish).  Upon pickup, the dialogue says for the berry, and same for the fish (just replace "berry" with "fish"):

{berry = berry + 1}You have {print berry} berries

2. Have a fire as a sprite. Open the advanced dialogue section (little purple square to the top-right of the dialogue box) for the fire sprite:

The fire dialogue is a conditional with three "when" clauses. The first "when" is the nested conditional checking to see if both berries and fish are in the inventory; if untrue, the same "when" then checks to see if berries alone are in the inventory:

Cleaned up for easier viewing:

{
    - fish >= 1 ?
        You have {print fish} fish and {print berry} berries. Cook?
    - else ?
        You have {print berry} berries. Cook berries?
}

The remaining two options are written as normal (making sure the "default" option is the last one):

How the entire text looks like in the general (non-advanced) dialogue box, you can either copy-paste all this into the sprite dialogue box or do as I did above and write it into the "advanced" boxes separately, either way the program will automatically recognize it:

{
  - {item "berry"} >= 1 ?
    {
      - fish >= 1 ?
        You have {print fish} fish and {print berry} berries. Cook?
      - else ?
        You have {print berry} berries. Cook berries?
    }
  - {item "fish"} >= 1 ?
    You have {print fish} fish. Cook fish?
  - else ?
    You have no raw food.
}}

Then this is how it looks in the game!