Checking Multiple Conditions in Puzzle Script

Ever wished you could check for more than one condition at a time in Puzzle Script, like is there a bomb on the stage AND a destructible block? This tutorial teaches how to check multiple conditions. It assumes no prior programming knowledge except the previous Puzzle Script tutorials I have written.


Checking For Multiple Conditions

Open the sample project. Now add this code to your project:

late [Player Switch][DoorClosed] -> [Player Switch][DoorOpen]

The code follows this format:

[ Condition 1 ] [ Condition 2 ] -> [ Action 1 ] [ Action 2 ]

If condition 1 is true, and condition 2 is true, then do action 1 and action 2. In this case, condition 1 is checking if the Player is on a Switch. If he is, then condition 2 is checked, which is, is there a closed door anywhere in the level? If the check is true, then the DoorClosed object becomes a DoorOpen object, opening the door.


Say we want the door to close when the hero steps off the switch though, because we want the player to push a crate onto the switch to keep it open. You can write something like this:

late [Player | Switch][DoorOpen] -> [Player | Switch][DoorClosed]

If the player is standing next to a switch, and there is an open door anywhere in the stage, close the door. Finally, we want to keep the door open if we push a crate onto the switch:

late [Crate Switch][DoorClosed] -> [Crate Switch][DoorOpen]

Now the door will stay open when there is a crate on the switch.


You can see the finished sample project here. The next tutorial covers how to create checkpoints in your games.

Follow this blog for more tutorials on Puzzle Script, games development and updates on my projects.

Next Tutorial >

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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