using { /Fortnite.com/Devices } using { /Fortnite.com/Game } using { /Fortnite.com/Characters } using { /Verse.org/Simulation } using { /Verse.org/Native } using { /UnrealEngine.com/Temporary/Diagnostics } # This is our main device. Think of it as the "Brain" of the crafting station. # It holds all the logic for what happens when a player interacts. crafting_station_device := class(creative_device): # These are editor-exposed device references. Wire them up in UEFN: # - TriggerDevice: a trigger_device placed in your Crafting Zone # - BaconGranter: an item_granter_device set to grant Bacon (count -1 to remove) # - PlankGranter: an item_granter_device set to grant Planks (count -1 to remove) # - RewardGranter: an item_granter_device set to grant the Makeshift Revolver # note: Verse has no runtime string-based inventory API; item_granter_device is # the supported way to give/remove items and act as a reward spawner. @editable TriggerDevice : trigger_device = trigger_device{} @editable BaconGranter : item_granter_device = item_granter_device{} @editable PlankGranter : item_granter_device = item_granter_device{} @editable RewardGranter : item_granter_device = item_granter_device{} # This is a VARIABLE. # Think of it as a label on a box. The box itself doesn't change, # but what's inside it (the value) can change during the game. # Here, we are creating a variable to track if the crafting was successful. var CraftingSuccess : logic = false # OnBegin runs once when the game session starts. # We use it to subscribe to the trigger's TriggeredEvent so our # crafting logic fires every time a player steps into the zone. OnBegin() : void = TriggerDevice.TriggeredEvent.Subscribe(OnPlayerEntered) # This function runs when a player steps into the trigger zone. # 'TriggeredAgent' is the agent (player) who entered. OnPlayerEntered(TriggeredAgent : ?agent) : void = # Unwrap the optional agent and confirm it is a fort_character # (i.e., an actual player in the game world, not a stray event). if (Agent := TriggeredAgent?): # item_granter_device tracks whether it successfully granted/removed # an item via its GrantedEvent. Here we attempt to remove ingredients # by calling GrantItem on granters configured with negative counts. # note: Configure BaconGranter and PlankGranter in UEFN with # Item Count = -1 so they remove one item each when triggered. # Attempt to remove Bacon and Plank by granting negative quantities. # GrantItem is called with parentheses since it always succeeds # (it does not have the 'decides' effect). BaconGranter.GrantItem(Agent) PlankGranter.GrantItem(Agent) # Both ingredients were present and removed — craft succeeded! # Now grant the reward. RewardGranter.GrantItem(Agent) # Mark the craft as successful. set CraftingSuccess = true # Optional: Print a message to the output log for debugging. Print("Crafting Complete! Here's your gun.")