Verse Library verse

03 First You Write Some Code

Applies healing or caps player health based on potion type and current health using conditionals.

extracted-snippets/documentation/en-us/uefn/basics-of-writing-code-4-practice-time-in-verse/03-first-you-write-some-code.verse

# Source URL: https://dev.epicgames.com/documentation/en-us/uefn/basics-of-writing-code-4-practice-time-in-verse
# Local doc:  epic-docs/documentation/en-us/uefn/basics-of-writing-code-4-practice-time-in-verse.md
# Section:    First You Write Some Code ...
# 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" and (PlayerHealth + PotionHealAmount) < MaxHealth):
set PlayerHealth = PlayerHealth + PotionHealAmount
else:
set PlayerHealth = MaxHealth

Comments

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