Help with coding for ordered events

Hello! I'm new to Plup, coding, and making games. I'm making a dungeon puzzle game, Never Eat Soggy Waffles, but I'm not sure how to code in the puzzles.

In this room, the player is meant to step on the blocks in a certain order, NSEW. Once they step on the blocks in that order, they would unlock the door and move on to the next room. But how would I make it so the blocks can be entered in that way and unlock the door when done?

Do you mean the player needs to stand on the single tiles that say "NSEW", or the larger square blocks towards the corners?

If its the latter, you might find it simpler to begin with to redraw these so they are each a single tile, rather than spread across 4 tiles each. That will make it easier to check which has been stood on and in what order without worrying about the player walking over multiple tiles of the same block. You can always then change it later after getting the code working!

In general you will want to use variables for keeping track of what the player has done in your game. In the code a variable can be assigned a value when the player does something, and that value can then be checked later on by something else. Sometimes you'll see these called flags as they "flag" what the player has done, especially when it's a simple "done" or "not done".

One of the best ways to code, especially as a beginner, is iteratively - start out with a very simple problem, get it working, then make it a bit more complicated, solve that, and repeat until you end up with what you really wanted.

In this case I would start by just coding a single button that unlocks a door, rather than four that need to be pressed in order.

Make your button as an item tile. This way we can make some code run when the player steps on it with its collect event:

on collect do
  // Make the button do something!

When the player steps on the button I would first check the value of a variable to see if the button has been pressed. If not I would open the door by swapping the door tile with a white tile, and then set the variable to indicate the button is now pressed (so the code won't run again if the player steps on the button again).

See if you can get that working! Once you do it'll be easier to build that up to four buttons being pressed in order :slight_smile: