Loading...

RSplit Documentation

Usage

Starting Your LiveSplit WebSocket Server

In order to use RSplit, you need to start a LiveSplit WebSocket Server. This feature has not been released yet, so you will have to either download a dev build or compile a build of the current master branch yourself. In your LiveSplit settings, make sure your "Server Port" is set to 16834 (the default). Once you've done that, right click on LiveSplit and go to the "Control" section and click "Start WebSocket Server."

Button to start WebSocket server

Using in a Run

To use this tool in a run, head to the AutoSplitter page and copy the code it gives you. If the game you are running has RSplit inside of it, there should be a place to enter this code in order to connect the game to your client. Once this is done, you're good to go! NOTE: It is essential that you leave the webpage open, and if you refresh you must enter a new code!

Testing

If you would like to test this tool, you can join this game and use these splits. (this game is uncopylocked, pardon my horrid testing code)

Development

Downloading the RSplit Module

You can download the RSplit module here. This module functions exclusively on the server.

Module Methods

Module methods include the following:

  • :GetTimer(player: Player) -> Timer
  • :RegisterPlayer(player: Player, code: string, reset: boolean?) -> Timer
  • :DeregisterPlayer(player: Player)
  • :PlayerIsRegistered(player: Player) -> boolean
  • :Send(player: Player, command: string) -> HTTP POST Reponse (string)
  • :ConvertToLSTime(seconds: number) -> string

Registering Players

The first thing you need to do is incorporate a way to get the player's code from them, whether it be them entering it into a TextBox or some other means. Once you have their code, register the player with :RegisterPlayer(). You can run this method with the same player multiple times and it will update their code to whatever is passed in. If you ever need to deregister a player, you can use the :DeregisterPlayer() method and it will remove the player you pass in. Players are deregistered automatically upon them leaving the game. If any LiveSplit commands are sent for an unregistered player, a warning will be printed to the console. Use the :PlayerIsRegistered() method to see if a player is registered.

If your game has multiple places you will have to save the player's code across games and reregister them as they join each place.

Timers

Upon registering a player, it creates and returns a Timer object that contains their Player object, connection code, and a series of methods granting control of their LiveSplit timer. In order to retrieve the player's Timer object, call the :GetTimer() method of the module and pass in the player. Timer methods include the following (and they all return the HTTP POST Response of the subsequent requests):

  • :StartTimer()
  • :Split(time: string?)
  • :Pause(time: string?)
  • :Resume(time: string?)
  • :Unsplit(time: string?)
  • :Reset()
  • :SwitchToGameTime()
  • :SwitchToRealTime()
  • :SetTime(time: string)
  • :Send(command: string)

All of these methods mirror default LiveSplit commands that can be found on the LiveSplit Server documentation with some having additional functionality. The Timer:Send() method takes in any LiveSplit Server command and redirects it to the :Send() method of the module. [if you would rather use the :Send() method of the module instead of any Timer methods, that is always an option]

Sending Commands and LiveSplit Timer Manipulation

You can control the LiveSplit timer through any of the Timer methods or by sending them through the module's :Send() method, passing in the player and any command from the LiveSplit Server documentation. LiveSplit Server commands that return a value will not return any value; this is a limitation of how the connection is made between the game and the client.

IMPORTANT: If you want to be able to modify/set the time on the timer of the player's LiveSplit client in ANY way (including handling load times), you must switch their LiveSplit timer to Game Time with Timer:SwitchToGameTime() first. Most people use Real Time and any sort of timer modification will not work on Real Time.

To set the user's LiveSplit time, use the Timer:SetTime() method passing in a string containing a time formatted like so: HH:MM:SS.FFFFFF. Any of these fields can be left out (i.e. you can pass in only seconds if you want to). If you want to convert some amount of seconds to this format, pass that time value into the module's :ConvertToLSTime() method and it will return the formatted string.

Ensuring Accuracy with Game Time

To avoid any mistiming issues that come with latency, it is suggested that you keep track of the player's time in game and set their time on LiveSplit before splitting, pausing, etc. This is obviously a little counterintuitive to the whole project but it's the best way to ensure accurate timing. The ideal way of doing this is using the optional time parameter of certain Timer methods which will chain multiple commands in one request to set the player's time and do the corresponding action at precisely the same time, eliminating virtually all latency. The value passed in to these functions should be a string formatted as specified in the previous subsection. Make sure the Timer is set to Game Time with Timer:SwitchToGameTime() if you are going to do this!

Chaining Commands

If you need two or more commands to run in extremely close proximity, you can pass multiple commands into either :Send() method by comma-separating them. Most Timer methods already utilise this feature to reduce latency and ensure accurate timing as specified in the previous section, but there are other ways to use it, too.
For example:
:Send("split, pause") -- Pause immediately after splitting

Thank You

Thank you for checking out this project! Please keep in mind that it is still in development and any bugs or suggestions should be sent to @j0nald on Discord.