# Login The login screen is the first screen you see that you can interact with when you open the game: ```{figure} ../../images/loginscreen.png ``` WaspLib's {ref}`TRSLogin` can handle both resizable and fixed mode login screens. - - - ## Lobby Methods to interact with the lobby screen - - - ## TRSLobbyScreen Simple record that handles the login lobby screen. The lobby screen is the screen you see after logging in with the large red button with "CLICK HERE TO PLAY". ```{figure} ../../images/lobby.png The lobbby screen. ``` - - - ## Lobby.Setup ```pascal procedure TRSLobbyScreen.Setup(); ``` Internal function that sets up the lobby screen coordinates. This is automatically called for you on the {ref}`Lobby variable`. - - - ## Lobby.IsOpen ```pascal function TRSLobbyScreen.IsOpen(): Boolean; ``` Returns True/False depending on whether the lobby screen is currently open. Example: ```pascal if Lobby.IsOpen() then Lobby.EnterGame(); ``` - - - ## Lobby.WaitOpen ```pascal function TRSLobbyScreen.WaitOpen(time: Integer = 600; interval: Integer = -1): Boolean; ``` Returns True/False if the lobby screen opens within `time` milliseconds. Example: ```pascal if Lobby.WaitOpen(2000) then Lobby.EnterGame(); ``` - - - ## Lobby.EnterGame ```pascal function TRSLobbyScreen.EnterGame(): Boolean; ``` Attempts to enter the game from the lobby screen. This is automatically called for you with {ref}`Login.DoLogin`. Example: ```pascal WriteLn Lobby.EnterGame(); ``` - - - ## Lobby variable Global {ref}`TRSLobbyScreen` variable. - - - ## Login World Switcher Methods to interact with the login world switcher - - - ## TRSLoginWorldSwitcher Reponsible for handling the login screen world switcher: ```{figure} ../../images/login_worldswitcher.png The login world switcher. ``` - - - ## TRSLoginWorldSwitcher.Setup ```pascal procedure TRSLoginWorldSwitcher.Setup(); ``` Internal method used to setup the {ref}`TRSLoginWorldSwitcher` coordinates. This is automatically called for you on the {ref}`LoginWorldSwitcher variable`. - - - ## LoginWorldSwitcher.IsOpen ```pascal function TRSLoginWorldSwitcher.IsOpen(): Boolean; ``` Returns True/False if the login screen world switcher is currently open. Example: ```pascal WriteLn LoginWorldSwitcher.IsOpen(); ``` - - - ## LoginWorldSwitcher.WaitOpen ```pascal function TRSLoginWorldSwitcher.WaitOpen(time: Integer = 600; interval: Integer = -1): Boolean; ``` Returns True/False if the login screen world switcher opens within `time` milliseconds. Example: ```pascal WriteLn LoginWorldSwitcher.WaitOpen(); ``` - - - ## LoginWorldSwitcher.Close ```pascal function TRSLoginWorldSwitcher.Close(): Boolean; ``` Attempts to close the login screen world switcher. Example: ```pascal if LoginWorldSwitcher.IsOpen() then LoginWorldSwitcher.Close(); ``` - - - ## LoginWorldSwitcher.Open ```pascal function TRSLoginWorldSwitcher.Open(): Boolean; ``` Attempts to open the login screen world switcher. Example: ```pascal if not LoginWorldSwitcher.IsOpen() then LoginWorldSwitcher.Open(); ``` - - - ## LoginWorldSwitcher.Read ```pascal function TRSLoginWorldSwitcher.Read(index: Integer): Integer; ``` Returns the number of the world box at the `index` you specify. Example: ```pascal if LoginWorldSwitcher.IsOpen() then WriteLn LoginWorldSwitcher.Read(0); ``` - - - ## LoginWorldSwitcher Pagination ```pascal function TRSLoginWorldSwitcher.PreviousPage(): Boolean; function TRSLoginWorldSwitcher.NextPage(): Boolean; ``` Attempts to switch the current login screen world switcher page using the `LoginWorldSwitcher.LeftButton` and `LoginWorldSwitcher.RightButton`. Returns True if we successfully changed page. Example: ```pascal if LoginWorldSwitcher.IsOpen() then LoginWorldSwitcher.NextPage(); ``` - - - ## LoginWorldSwitcher GetCurrent ```pascal function TRSLoginWorldSwitcher.GetCurrent(): Integer; ``` Attempts to get our currently selected world. For this, if the login screen world switcher is open, we close it first, as the current world can only be read from the login screen. Example: ```pascal WriteLn LoginWorldSwitcher.GetCurrent(); ``` - - - ## LoginWorldSwitcher.Find ```pascal function TRSLoginWorldSwitcher.Find(world: Integer; out index: Integer): Boolean; ``` Attempts to find the specified `world`. For this, {ref}`LoginWorldSwitcher Pagination` will be used if required. If the world we specified is found, the function returns `True` and the index of of the button is returned through `index`. Example: ```pascal WriteLn LoginWorldSwitcher.Find(303, idx); ``` - - - ## LoginWorldSwitcher.Switch ```pascal function TRSLoginWorldSwitcher.Switch(world: Integer): Boolean; ``` Attempts to switch to the specified `world`. For this, {ref}`LoginWorldSwitcher Pagination` will be used if required. If the world we specified is found and we successfully switch to it the function returns `True`. Example: ```pascal WriteLn LoginWorldSwitcher.Switch(303); ``` - - - ## LoginWorldSwitcher variable Global {ref}`TRSLoginWorldSwitcher` variable. - - - (LOGIN_MESSAGES)= # const LOGIN_MESSAGES ```pascal LOGIN_MESSAGES = [ 'Welcome to RuneScape', 'Connecting to server', 'Invalid credentials', 'Incorrect username or password', 'You need a skill total of', 'Please enter your username/email', 'Error connecting to server', 'Your account has not logged out', 'Login server offline', 'Error loading your profile', 'Connection timed out', 'You were disconnected', 'Login limit exceeded', 'This world is full', 'Your account has been', 'You need a members account', 'You are standing in a members-only area', 'Authenticator' ]; ``` Constant of all the login messages the login screen can handle. - - - ## Login Enums ```pascal ERSLoginMode = enum(UNKNOWN, LEGACY, LAUNCHER); ERSLoginButton = enum(LAUNCHER, EXISTING_USER, LOGIN, RETRY, OKAY, CONTINUE); ERSLoginInput = enum(USERNAME, PASSWORD); ERSLoginMessage = enum( UNKNOWN, WELCOME, CONNECTING, INVALID, INCORRECT, SKILL_TOTAL, ENTER_CREDENTIALS, ERROR_CONNECTING, Player_ONLINE, SERVER_OFFLINE, ERROR_LOADING, TIMED_OUT, DISCONNECTED, LIMIT_EXCEEDED, WORLD_FULL, BANNED, NOT_MEMBER, ON_MEMBER_AREA, AUTHENTICATOR ); ``` Enums representing various aspects of the login screen. `ERSLoginMessage` is a enum representation of {ref}`LOGIN_MESSAGES`. - - - ## TRSLogin Main record responsible for handling the {ref}`Login` screen. ```{figure} ../../images/trslogin.png The login screen. ``` - - - ## Login.Setup ```pascal procedure TRSLogin.Setup(); ``` Internal method responsible for setting up the {ref}`TRSLogin` coordinates. This is automatically called for you on the {ref}`Login variable`. - - - ## Login.FindButton ```pascal function TRSLogin.FindButton(button: ERSLoginButton): Boolean; ``` Attempts to find the specified `ERSLoginButton`, returns `True` if we find it. - - - ## Login.ClickButton ```pascal function TRSLogin.ClickButton(button: ERSLoginButton): Boolean; ``` Attempts to click the specified `ERSLoginButton`, returns `True` if we succeed. Example: ```pascal WriteLn Login.ClickButton(ERSLoginButton.LOGIN); ``` - - - ## Login.SelectInput ```pascal function TRSLogin.SelectInput(field: ERSLoginInput): Boolean; ``` Attempts to select the specified `ERSLoginInput`, returns `True` if we succeed. This waits a few milliseconds for the flashing yellow cursor for confirmation. Example: ```pascal WriteLn Login.SelectInput(ERSLoginInput.USERNAME); ``` - - - ## Login.InputIsFilled ```pascal function TRSLogin.InputIsFilled(field: ERSLoginInput): Boolean; ``` Returns True/False if the specified `field` is filled. Example: ```pascal WriteLn Login.InputIsFilled(ERSLoginInput.USERNAME); ``` - - - ## Login.ClearInput ```pascal function TRSLogin.ClearInput(field: ERSLoginInput): Boolean; ``` Attempts to clear the specified `field`. Example: ```pascal WriteLn Login.ClearInput(ERSLoginInput.USERNAME); ``` - - - ## Login.FillInput ```pascal function TRSLogin.FillInput(field: ERSLoginInput; details: String): Boolean; ``` Attempts to fill the specified `field` with `details`. Example: ```pascal WriteLn Login.FillInput(ERSLoginInput.USERNAME, 'myPlayer@email.com'); ``` - - - ## Login.GetMessage ```pascal function TRSLogin.GetMessage(): ERSLoginMessage; ``` Returns the currently visible login message as a `ERSLoginMessage`. Check {ref}`Login Enums` for more information on `ERSLoginMessage`. Example: ```pascal WriteLn Login.GetMessage(); ``` - - - ## Login.GetMode ```pascal function TRSLogin.GetMode(): ERSLoginMode; ``` Returns the current login mode as a `ERSLoginMode`. The login mode can only be known from the "Welcome to RuneScape" screen. Check {ref}`Login Enums` for more information on `ERSLoginMode`. Example: ```pascal WriteLn Login.GetMode(); ``` - - - ## Login.HandleWelcome ```pascal function TRSLogin.HandleWelcome(): Boolean; ``` Attempts to handle the "Welcome to RuneScape" screen regardless of the `ERSLoginMode` the client is on. Check {ref}`Login Enums` for more information on `ERSLoginMode`. Example: ```pascal WriteLn Login.HandleWelcome(); ``` - - - ## Login.Back2Welcome ```pascal function TRSLogin.Back2Welcome(): Boolean; ``` Attempts to return to the "Welcome to RuneScape" screen. This is used to handle any screen that has an "Ok" button. Returns True if we succeed. Example: ```pascal WriteLn Login.Back2Welcome(); ``` - - - ## Login.EnterCredentials ```pascal function TRSLogin.EnterCredentials(username, password: String): Boolean; ``` Attempts to enter a user credentials. Example: ```pascal WriteLn Login.EnterCredentials('username', 'password'); ``` - - - ## Login.Retry ```pascal function TRSLogin.Retry(msg: ERSLoginMessage): Boolean; ``` Attempts to handle any screen that has a "Retry" button. Returns True if we succeed. The current `ERSLoginMessage` message has to be passed as `msg` so we know when we successfully handled the button. - - - ## Login.HandleError ```pascal function TRSLogin.HandleError(msg: ERSLoginMessage): Boolean; ``` Attempts to handle any screen that has an error message. Returns True if we succeed. The current `ERSLoginMessage` message has to be passed as `msg` so we know when we successfully handled the current error. Everytime this function is called, the internal `Login.Attempts` variable is increased. After 10 times of this being called without `Login.Attempts` being reset, this will raise an exception **IF** the reason we can't login is not the world being full. **IF** the reason is the world being full, this can be called forever. - - - ## Login.HandleMessage ```pascal function TRSLogin.HandleMessage(msg: ERSLoginMessage; username, password: String): Boolean; ``` Attempts to handle whatever screen the login screen is currently at. Returns True if we succeed. The current `ERSLoginMessage` message has to be passed as `msg` so we know when we successfully handled the current error. The Player `username` and `password` we want to use also have to be passed in. This can be empty value if we are using the Jagex Launcher, e.g.: `'', ''`. On certain `ERSLoginMessages` that cannot be handled this will raise an exception to shutdown your script. For example, if the Player you are trying to use has been banned. - - - ## Login.DoLogin ```pascal function TRSLogin.DoLogin(player: TRSPlayer): Boolean; ``` Attempts to login into `player`. If we login, the {ref}`Lobby` screen is handled for you. Returns true if we succeed. Example: ```pascal WriteLn Login.DoLogin(player); ``` - - - ## Login variable Global {ref}`TRSLogin` variable.