using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Fortnite.com/FortPlayerUtilities } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # Create a new Verse device. Think of this as a "Brain" attached to a device. # It lives in the world and reacts to events. powder_processor := class(creative_device): # Wire this to a Trigger device placed in your UEFN scene. # Players walk into the trigger to start the crafting check. @editable CraftTrigger : trigger_device = trigger_device{} # Wire this to an Item Granter device set to grant a Shield Potion. # The Item Granter handles the actual item delivery to the player. @editable RewardGranter : item_granter_device = item_granter_device{} # Wire this to an Item Remover device configured to remove # Rough Mineral Powder (quantity 1) from the player's inventory. @editable PowderRemover : item_remover_device = item_remover_device{} # OnBegin runs once when the island loads — your "Start Game" event. OnBegin() : void = # Subscribe to the trigger's TriggeredEvent so we react every # time a player walks into the trigger zone. CraftTrigger.TriggeredEvent.Subscribe(OnPlayerTriggered) # Keep the coroutine alive so subscriptions stay active. Sleep(Inf) # This function fires each time the trigger is activated by a player. OnPlayerTriggered(TriggeringAgent : ?agent) : void = # Cast the generic agent to a fort_character so we can act on them. # The `if` here is a safe cast — it only runs if the cast succeeds. if (Agent := TriggeringAgent?): if (Player := Agent.GetFortCharacter[]): # Item Granter delivers the Shield Potion reward to the player. # Configure the Item Granter device in the editor to grant # 1x Shield Potion. GrantItem() targets the triggering player. RewardGranter.GrantItem(Agent) # Item Remover consumes the Mineral Powder crafting cost. # Configure the Item Remover device in the editor to remove # 1x Rough Mineral Powder. Remove() targets the triggering player. PowderRemover.Remove(Agent) # Print a confirmation to the UEFN output log. # In a shipped map swap this for a UI device message instead. Print("Crafted! You traded powder for a shield.")