# RegretTrap.verse
using { /Fortnite.com/Devices }
using { /Fortnite.com/Components/Interaction }
# This is our custom function.
# The <transacts> tag means: "If this function fails, undo any changes it made."
# Think of it as: "Try to damage, but if you can't, pretend we never tried."
DamagePlayer(Player : Player)<transacts> : void =
(
# We attempt to deal damage.
# If this line fails (e.g., Player is invalid, or damage is blocked),
# the entire function "rolls back" to the state before it was called.
Player.Damage(50.0)
)
# This is the event that runs when someone interacts with the trigger
OnInteracted(Trigger : Trigger, Player : Player) : void =
(
# We call our damage function. Because it has <transacts>,
# it’s safe to call here. If it fails, the game state is clean.
DamagePlayer(Player)
)
Verse Library
verse
01 Fragment
Safe damage function using transacts to automatically rollback changes if the operation fails.
verse-library/effects/01-fragment.verse