Hi @NoaLahav and welcome to the forums!
you can save items as variables and perform a check at a later time to see if the item that is required has been picked up before. Below is an example on how to achieve that.
How it works
- We make a variable that keeps track of all items in our inventory. We call it “inventory” and make it an empty list at start
- When the starfish is clicked, it is added to the inventory list. We then hide the item out of sight of the player
- When the door is clicked, we check if the starfish can be found in the list. If yes, the door opens. If not, the door tells us to take the starfish
list ... find first occurence of item - block will return the number 0 if the item we’re looking for is not found. We check if the returned number is not 0 so we know that the item we’re looking for has been found).
Blockly code in action
I hope this example helps! It’s already using programming concepts like lists, which make your inventory system more flexible but a little more challenging to get into. Below, you can find a simpler version in which the inventory can only hold one item at a time.
Watch simplified example code