# WorldSwitcher WorldSwitcher is resposible for changing worlds with the logged in world switcher in the {ref}`Logout` gametab. ```{figure} ../../images/worldswitcher.png ``` - - - ## EWorldSwitcherButton enum ```pascal EWorldSwitcherButton = enum(CONFIGURE, CLOSE, LOGOUT); ``` Enum representing the world switcher buttons. - - - ## TWorld type Helper record for {ref}`TworldSwitcher`. - - - ## TWorldArray type Helper type for {ref}`TworldSwitcher`. - - - ## TWorldSwitcher type Main record that interacts with the {ref}`WorldSwitcher`. - - - ## TWorldSwitcher.Setup ```pascal procedure TWorldSwitcher.Setup(); ``` Interal method used to setup the {ref}`TWorldSwitcher` cooldown. This is automatically called for you on the {ref}`WorldSwitcher variable`. - - - ## TWorldSwitcher.SetupGameTab ```pascal procedure TWorldSwitcher.SetupGameTab(); ``` Interal method used to setup the {ref}`TWorldSwitcher` coordinates. This is automatically called for you on the {ref}`WorldSwitcher variable`. - - - ## WorldSwitcher.IsOpen ```pascal function TWorldSwitcher.IsOpen(): Boolean; ``` Returns true if the world switcher is open. Example: ```pascal WriteLn WorldSwitcher.IsOpen(); ``` - - - ## WorldSwitcher.IsLoading ```pascal function TWorldSwitcher.IsLoading(): Boolean; ``` Returns true if the world switcher is loading. The world switcher takes a few milliseconds to load. Example: ```pascal WriteLn WorldSwitcher.IsLoading(); ``` - - - ## WorldSwitcher.WaitLoading ```pascal function TWorldSwitcher.WaitLoading(time: Integer = 600; interval: Integer = -1): Boolean; ``` Waits for the world switcher to finish loading. For more information on loading read {ref}`WorldSwitcher.IsLoading`. Example: ```pascal WriteLn WorldSwitcher.WaitLoading(); ``` - - - ## WorldSwitcher.Open ```pascal function TWorldSwitcher.Open(waitLoad: Boolean = True): Boolean; ``` Attempts to open the world switcher. This method is overriden after {ref}`Logout`, for more information check {ref}`WorldSwitcher.Open override`. Example: ```pascal WriteLn WorldSwitcher.Open(); ``` - - - ## Logout.CloseWorldSwitcher ```pascal function TLogout.CloseWorldSwitcher(): Boolean; ``` Closes the world switcher. Example: ```pascal Logout.CloseWorldSwitcher(); ``` - - - ## WorldSwitcher.Logout ```pascal function TWorldSwitcher.Logout(attempts: UInt32 = 5; time: UInt32 = 20000): Boolean; ``` Clicks the logout button. Returns true if we succesfully logout of the game. Example: ```pascal WriteLn WorldSwitcher.Logout(); ``` - - - ## WorldSwitcher.GetWorlds ```pascal function TWorldSwitcher.GetWorlds(): TWorldArray; ``` Returns the currently visible {ref}`TWorldArray`. Example: ```pascal ShowOnTarget(WorldSwitcher.Worlds); ``` - - - ## WorldSwitcher.FindWorld ```pascal function TWorldSwitcher.FindWorld(number: Integer; out world: TWorld): Boolean; ``` Returns true if the specified world `number` is found. The world data is returned through the `world` variable. Example: ```pascal if WorldSwitcher.FindWorld(311, world) then ShowOnTarget([world]); ``` - - - ## WorldSwitcher.IsSorted ```pascal function TWorldSwitcher.IsSorted(): Boolean; ``` Checks if the worlds in the world switcher are sorted. Example: ```pascal WriteLn WorldSwitcher.IsSorted(); ``` - - - ## WorldSwitcher.Sort ```pascal function TWorldSwitcher.Sort(): Boolean; ``` Sorts the worlds from lower to higher numbers. Example: ```pascal WriteLn WorldSwitcher.Sort(); ``` - - - ## WorldSwitcher.World property ```pascal property TWorldSwitcher.World: Integer; property TWorldSwitcher.World(next: Integer): Boolean; ``` Returns or sets the current world we are on. Setting a new world will only happen if `TWorldSwitcher.Cooldown` is finished, which is a cooldown that starts everytime you change worlds. Example: ```pascal WriteLn WorldSwitcher.World; WorldSwitcher.World := 311; WriteLn WorldSwitcher.World; ``` - - - ## WorldSwitcher.Next ```pascal function TWorldSwitcher.Next(): Boolean; ``` Hops to the world that follows our current world according to the contents of `Profiles.Get().Worlds`. Example: ```pascal WriteLn WorldSwitcher.World; WorldSwitcher.Next(); WriteLn WorldSwitcher.World; ``` - - - ## WorldSwitcher.Previous ```pascal function TWorldSwitcher.Previous(): Boolean; ``` Hops to the world that comes before our current world according to the contents of `Profiles.Get().Worlds`. Example: ```pascal WriteLn WorldSwitcher.World; WorldSwitcher.Previous(); WriteLn WorldSwitcher.World; ``` - - - ## WorldSwitcher.Random ```pascal function TWorldSwitcher.Random(): Boolean; ``` Hops to a random world that's in `Profiles.Get().Worlds` and is not our current world. Example: ```pascal WriteLn WorldSwitcher.World; WorldSwitcher.Random(); WriteLn WorldSwitcher.World; ``` - - - ## WorldSwitcher.WaitSwitch ```pascal function TWorldSwitcher.WaitSwitch(world: Integer; failCooldown: Boolean = True): Boolean; ``` Exits false if "Please wait" not found, presumably due to combat. Returns true if we find "Please wait" and finish world hopping successfully to the specified `world` - - - ## WorldSwitcher variable Global {ref}`TWorldSwitcher` variable.