Verse Library verse

02 Fragment

Imports and uses external Verse modules to share game data like potion stats, promoting code reuse and organization.

verse-library/creating-custom-modules/02-fragment.verse

# MainGame.verse
# This is the "Player" script. It uses the data from the Loot Pool.

# IMPORT THE MODULE
# This is like saying "Give me access to the PotionData file."
using PotionData

# This is the main entry point for your island logic
Main := @subscribe:
    (event: GameStarted) ->
        # Let's print out the info from our module to prove it works.
        # We access the module's data using the dot notation (Module.Variable).
        Print($"Potion Name: {PotionData.PotionName}")
        Print($"Heal Amount: {PotionData.HealAmount}")
        Print($"Cooldown: {PotionData.CooldownTime} seconds")

        # Now, let's simulate healing a player using that data.
        # Imagine we have a player object here.
        # Player.Health += PotionData.HealAmount
        # Print("Player healed! Thanks to the module!")

Comments

    Sign in to vote, comment, or suggest an edit. Sign in