using { /Fortnite.com/Devices } using { /Fortnite.com/Playspaces } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # ----------------------------------------------------------------------------- # lobby_manager — Indie Island tutorial 04: Onboarding # # Makes the lobby exit teleporter work ONCE per player. # # Setup (Details panel): # 1. LobbyTeleporter = the teleporter players walk into at the lobby exit. # CLEAR its own destination link. Otherwise the device teleports on every # overlap by itself, whatever this code says. # 2. ArrivalTeleporter = a teleporter in the world where players should land. # Teleport() sends a player TO this device. # # The "already used" memory lives in this session only: a player who leaves and # rejoins can use the door again. To make it permanent, store the flag in a # persistable class instead (see tutorial 02). # ----------------------------------------------------------------------------- lobby_manager := class(creative_device): @editable LobbyTeleporter : teleporter_device = teleporter_device{} @editable ArrivalTeleporter : teleporter_device = teleporter_device{} # Who has already gone through the door this session. var PlayersEntered : [player]logic = map{} OnBegin() : void = LobbyTeleporter.EnterEvent.Subscribe(OnEnter) OnEnter(Agent : agent) : void = if (Player := player[Agent]): # Not in the map yet = never used the door. AlreadyUsed := if (U := PlayersEntered[Player]) then U else false if (AlreadyUsed = false): # Map writes can fail, so they sit inside an if. Empty block on purpose. if (set PlayersEntered[Player] = true) {} ArrivalTeleporter.Teleport(Player)