# ConditionalScoreTrigger.verse # Only award points if the player is currently holding a Pickaxe (any item in slot 0). # Demonstrates conditional logic before calling score_manager_device.Activate(). using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Fortnite.com/Game } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } ConditionalTrigger := class(creative_device): # Wire this to a Trigger device in the editor (the capture zone). @editable CaptureTrigger : trigger_device = trigger_device{} # Wire this to a Score Manager device configured for the correct team. @editable TeamScoreManager : score_manager_device = score_manager_device{} # Wire this to a Class Selector or Item Spawner that hands out the required item. # We use a class_and_team_selector_device as a proxy to identify which players # already received the "flag" item, since direct inventory inspection APIs # are not yet exposed in public Verse. See note below. # note: Full item-in-hand inspection (e.g. GetEquippedItem) is not available in # the current public Verse API. The pattern below uses a boolean flag set # by a separate device (e.g. an Item Granter + Trigger that calls # SetHasItem() via a custom event) to approximate the check. var HasRequiredItem : logic = false OnBegin() : void = # Subscribe to the trigger so we run our conditional check on entry. CaptureTrigger.TriggeredEvent.Subscribe(OnZoneEntered) # Call this from another device or Verse script when the player picks up the flag item. SetHasItem(Value : logic) : void = set HasRequiredItem = Value # Fires when a player enters the capture zone trigger. OnZoneEntered(MaybeAgent : ?agent) : void = if (LiveAgent := MaybeAgent?): # Only award the point when our flag condition is satisfied. if (HasRequiredItem?): TeamScoreManager.Activate(LiveAgent) # Reset the flag so the point can only be scored once per pickup. set HasRequiredItem = false