# This script makes a potion shop work. # We need to talk to the button and the player. # A "Device" is any object in our game world. # We use "Event" to wait for something to happen. Event OnPlayerInteracts(player: Player, button: TextButton): # Check if the player is the one pressing the button. # We use "if" to ask a question. if button.IsPressed(player): # Check the player's score. # Score is like a variable that counts points. # We treat score as "coins" for this shop. coins := player.GetScore() # Does the player have 10 coins? if coins >= 10: # Take 10 coins away. # This is like paying for the item. player.SetScore(coins - 10) # Give the player a Health Potion. # We use "Grant" to add an item to their inventory. # "Health_Potion" is the name of the item. player.Grant(Health_Potion) # Tell the player "Thanks!" # We use "ShowMessage" to talk to them. player.ShowMessage("You bought a potion!") else: # Not enough coins. player.ShowMessage("You need 10 coins!")