Making a Locked Chest#

Here are the steps for making a locked chest:

  1. Make a new Sprite that looks like a chest and call it chest.

  2. Make a new Sprite that looks like a coin and call it coin.

  3. Make a new Sprite that looks like a key and call it key.

  4. Make a new Item called coin and give it the coin Sprite.

  5. Make a new Item called key and give it the key Sprite.

  6. Make a new Thing called locked chest and give it the chest Sprite.

  7. Add a new Action Sequence to your locked chest Thing.

  8. Add a Make a Decision Action.

  9. For the If Action, set the condition to if key >= 1.

  10. For the If Action, add a Do Actions in a Row Action.

  11. For the first sub-Action, add a Group of Actions Action.

  12. In the Group of Actions, add an Increase Item Count Action that adds 5 coins.

  13. In the Group of Actions, after the Increase Item Count, add a Say Something Action that says something like, “You unlocked the chest and found 5 coins!"

  14. After the Group of Actions, add a Do Nothing Action.

  15. For the Else Action, add a Say Something Action that says something like, “The chest is locked!”.

  16. Put a key Item in your game and a locked chest in your game.

  17. Hit Play and test it out!

NOTE: Why does this work?
When you walk up to the chest, it first checks to see if you have at least 1 key. If you do, it goes on to the next thing, which is the Group of Actions. The first time you walk up to the chest with a key, the first Action in the Group of Actions will happen, which is to give you 5 coins. The second, and every other time, you walk up to the chest with a key, it will do nothing. However, if you walk up to the chest with no key, it will tell you the chest is locked.

Here is what the Action Sequence should look like:

  • Make a Decision
    • If - key >= 1
      • Do Actions in a Row
        • Group of Actions
          • Increase Item Count - coin += 5
          • Say Something - “You unlocked the chest and found 5 coins!”
        • Do Nothing
    • Else
      • Say Something - “The chest is locked!”