using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /Verse.org/Native } using { /UnrealEngine.com/Temporary/Diagnostics } # This is our main script class. # It holds all our health logic. health_manager := class(creative_device): # This is a variable for health. # It starts at 100. # Think of it as a box holding the number 100. var CurrentHealth : float = 100.0 # This is a variable for shields. # It starts at 50. var CurrentShield : float = 50.0 # This function updates the health bar. # It takes the new health value as input. UpdateHealthBar(NewHealth : float) : void = # Check if the new health is valid. # Health cannot be negative. if (NewHealth < 0.0): set CurrentHealth = 0.0 else: set CurrentHealth = NewHealth # Print a message to see it working. Print("Health is now: {CurrentHealth}") # This function updates the shield bar. UpdateShieldBar(NewShield : float) : void = # Check if the new shield is valid. if (NewShield < 0.0): set CurrentShield = 0.0 else: set CurrentShield = NewShield # Print a message to see it working. Print("Shield is now: {CurrentShield}") # This is an event. # It runs when the actor starts. OnBegin() : void = # Say hello when the game starts. Print("Health System Started!") Print("Starting Health: {CurrentHealth}") Print("Starting Shield: {CurrentShield}")