# This is a comment. The game ignores it. # It is for us to read. using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } Create_Mushroom_Grant := class(creative_device): # This is our main device. # It will grant the mushroom. # This is the Item Granter device. # Place one in your island and connect it here. # Set it to give a Shield Mushroom in its device properties. @editable item_granter : item_granter_device = item_granter_device{} # This is the trigger device. # Place one in your island and connect it here. # It fires when a player touches the device. @editable mushroom_trigger : trigger_device = trigger_device{} # OnBegin runs automatically when the game starts. # We use it to subscribe to the trigger's event. OnBegin() : void = # Tell the trigger to call our function when touched. # 'TriggeredEvent' fires and gives us the agent who touched it. mushroom_trigger.TriggeredEvent.Subscribe(OnMushroom_Touched) # This function runs when a player touches the trigger. # 'who' is the agent (player) who touched it. OnMushroom_Touched(who : ?agent) : void = # We give the item to the player using the Item Granter device. # # note: item_granter_device.GrantItem() targets a specific agent. if (Agent := who?): item_granter.GrantItem(Agent)