# This is the main script for our Surprise Spinner using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /Verse.org/Random } # This is the main class for our device surprise_spinner := class(creative_device): # These are the items we can give away # We link them to the Item Granters in the editor @editable sword_granter : item_granter_device = item_granter_device{} @editable shield_granter : item_granter_device = item_granter_device{} # This is the trigger a player walks into to spin the wheel # We link it to a Trigger device placed in the editor @editable spin_trigger : trigger_device = trigger_device{} # This function runs automatically when the game starts OnBegin() : void = # We subscribe to the trigger so we know when a player steps on it spin_trigger.TriggeredEvent.Subscribe(OnSpinTriggered) # This function runs when a player triggers the device OnSpinTriggered(Agent : agent) : void = # We roll a random integer between 1 and 2 inclusive # 1 means Sword, 2 means Shield # GetRandomInt returns a value in the range [Low, High] Result : int = GetRandomInt(1, 2) # The 'Result' is the number the RNG picked if (Result = 1): # If it rolled a 1, give the sword! sword_granter.GrantItem(Agent) else if (Result = 2): # If it rolled a 2, give the shield! shield_granter.GrantItem(Agent)