# This is our main script file using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Fortnite.com/Playspaces } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # We create a new type of device called CrystalCraftingStation CrystalCraftingStation := class(creative_device): # This is the button the player clicks @editable my_button: button_device = button_device{} # This is the spawner that gives the item @editable my_spawner: item_spawner_device = item_spawner_device{} # This runs when the game starts OnBegin():void= # Subscribe to the button's activation event. # ActivatedEvent fires with the agent (player) who pressed it. my_button.InteractedWithEvent.Subscribe(OnActivated) # This function runs when the button is pressed # agent is the player who clicked the button OnActivated(Agent : agent) : void = # Try to get the fort_character from the agent so we can check inventory if (Character := Agent.GetFortCharacter[]): # Spawn the reward item and give it to the player my_spawner.SpawnItem() else: # nothing to do if the player lacks the crystal; # the Conditional Button's own settings will have already # blocked the interaction, but this branch is a safety net Print("Player does not have a Rainbow Crystal.")