# Source URL: https://dev.epicgames.com/documentation/en-us/uefn/learn-code-basics-4-practice-time-in-verse
# Local doc: epic-docs/documentation/en-us/uefn/learn-code-basics-4-practice-time-in-verse.md
# Section: Complete Script
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
hello_world_device := class(creative_device):
# Runs when the device is started in a running game
OnBegin<override>()<suspends> : void =
MaxHealth : float = 100.0
MinHealth : float = 1.0
var PotionType: string = "heal"
set PlayerHealth = 80.0
# Code to run if player drinks a healing potion
# If the player's health would not exceed MaxHealth if they were healed,
# heal them the full amount
if (PotionType = "heal"):
if ((PlayerHealth + PotionHealAmount) < MaxHealth):
set PlayerHealth = PlayerHealth + PotionHealAmount
Print ("Full heal")
else:
# else, set PlayerHealth the MaxHealth
set PlayerHealth = MaxHealth
Print("PlayerHealth too high for full heal")
# Code to run if player drinks a damaging potion
Verse Library
verse
07 Complete Script
Manages player health by applying healing or damage potions while respecting maximum and minimum health limits.
extracted-snippets/documentation/en-us/uefn/learn-code-basics-4-practice-time-in-verse/07-complete-script.verse
Sign in free to read the full source 🌴
This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.