# This is a Verse script for the Mystery Cooler
# We create a device for our cooler.
# Think of this as giving the cooler a name tag.
device: object = world.GetRootDevice()
# This is a function.
# A function is a list of steps to do.
# We call it "PickSnack".
PickSnack(): void =>
# We make a random number between 1 and 3.
# This is like rolling a 3-sided die.
snack_choice := world.GetRandomInt(1, 3)
# We check which number we rolled.
if snack_choice == 1:
# If it is 1, give an Apple.
device.GrantItem("Apple")
elif snack_choice == 2:
# If it is 2, give a Pepper.
device.GrantItem("Pepper")
else:
# If it is 3, give a Mushroom.
device.GrantItem("Mushroom")
# This part connects the code to the game.
# It waits for the "On Interacted With" event.
# When this event happens, we run PickSnack().
device.OnInteractedWith(PickSnack)
Verse Library
verse
01 Fragment
Grants a random consumable item when a player interacts with the cooler object.
verse-library/cooler/01-fragment.verse