# WorldSwitcher WorldSwitcher is resposible for changing worlds with the logged in world switcher in the {ref}`Logout` gametab. ```{figure} ../../images/worldswitcher.png ``` - - - ## ERSWorldSwitcherButton ```pascal ERSWorldSwitcherButton = enum(CONFIGURE, CLOSE, LOGOUT); ``` Enum representing the world switcher buttons. - - - ## TRSWorld Helper record for {ref}`TRSworldSwitcher`. - - - ## TRSWorldArray Helper type for {ref}`TRSworldSwitcher`. - - - ## TRSWorldSwitcher Main record that interacts with the {ref}`WorldSwitcher`. - - - ## TRSWorldSwitcher.SetupGameTab ```pascal procedure TRSWorldSwitcher.SetupGameTab(); ``` Interal method used to setup the {ref}`TRSWorldSwitcher` coordinates. This is automatically called for you on the {ref}`WorldSwitcher variable`. - - - ## WorldSwitcher.IsOpen ```pascal function TRSWorldSwitcher.IsOpen(): Boolean; ``` Returns true if the world switcher is open. Example: ```pascal WriteLn WorldSwitcher.IsOpen(); ``` - - - ## WorldSwitcher.IsLoading ```pascal function TRSWorldSwitcher.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 TRSWorldSwitcher.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 TRSWorldSwitcher.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 TRSLogout.CloseWorldSwitcher(): Boolean; ``` Closes the world switcher. Example: ```pascal Logout.CloseWorldSwitcher(); ``` - - - ## WorldSwitcher.Logout ```pascal function TRSWorldSwitcher.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.GetCurrentWorld ```pascal function TRSWorldSwitcher.GetCurrentWorld(): Integer; ``` Returns the current world we are on. Example: ```pascal WriteLn WorldSwitcher.GetCurrentWorld(); ``` - - - ## WorldSwitcher.GetWorlds ```pascal function TRSWorldSwitcher.GetWorlds(): TRSWorldArray; ``` Returns the currently visible {ref}`TRSWorldArray`. Example: ```pascal ShowOnTarget(WorldSwitcher.GetWorlds()); ``` - - - ## WorldSwitcher.FindWorld ```pascal function TRSWorldSwitcher.FindWorld(number: Integer; out world: TRSWorld): 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 TRSWorldSwitcher.IsSorted(): Boolean; ``` Checks if the worlds in the world switcher are sorted. Example: ```pascal WriteLn WorldSwitcher.IsSorted(); ``` - - - ## WorldSwitcher.Sort ```pascal function TRSWorldSwitcher.Sort(): Boolean; ``` Sorts the worlds from lower to higher numbers. Example: ```pascal WriteLn WorldSwitcher.Sort(); ``` - - - ## WorldSwitcher.WaitSwitch ```pascal function TRSWorldSwitcher.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.Hop ```pascal function TRSWorldSwitcher.Hop(worlds: TIntegerArray): Boolean; ``` Switches to a different world from the specified `worlds`. By default the world switcher will sort the worlds, you can change this by passing `False` to `sort`. If the `TRSWorldSwitcher.Cooldown` is still active the function will return `False`. Example: ```pascal WriteLn WorldSwitcher.Hop([303, 304, 305]); ``` - - - ## WorldSwitcher variable Global {ref}`TRSWorldSwitcher` variable.