For more information on items not covered within this document, please head over to our forums and start a discussion!
Currently, the lobby system needs to be opened as a Table Realms project file, and the existing assets should be switched out with whichever assets you would like to use in your project.
Important Note: When importing your assets, ensure that there are no name duplications between existing assets and assets being imported.
The hierarchy and layouts should not need to be changed.
Future iterations of the lobby system will allow it to be imported, much like base.lua and other scripts.
In order to show the qr code you need to add an image component to the layout of the page, and name it QR1 or QR2. This relates to the fact that there are both horizontal and vertical lobby layouts, and it’s not a good idea to call two different components by the same name within the TR IDE.
If you’re using a pre-existing template, then you will have a Start button present. Ensure that the Start() function is present in the script field of the button, in order to send a start action to the game.
It’s helpful, but not 100% necessary, to create a companion player manager in your game. This will contain helper functions for managing players within your game.
Author’s Note: I might move my stuff into lua if it is deemed necessary, or we will create an equivalent in Construct2/3
Max and min player settings can be found in the lobby script as local variables. Ensure that you have your game specific values assigned to these variables, to trigger the enabled/disabled state of the “Start” and “Join” buttons.
The Avatar component can be added like a normal image component, by specifying a placeholder image and a ready image. If the ready image is not nil, it will be used when a players ready flag is set.
The index value of the Avatar is what is used to assocciate it to a player. This means the avatar with an index of 1 will display the first player’s avatar and ready state.
These values can be retrieved anywhere from the model.
player.[player id].lobby.avatar
This contains the Base64 string of the players avatar.
player.[player id].lobby.ready
String flag for when a player is ready in the current session (‘true’ or ‘false’).
player.[player id].lobby.color
The colour assigned to the specific player ID (format: red|green|blue in 0-1 values)
player.[player id].lobby.roundsPlayed
The total number of rounds the player has played.
player.[player id].lobby.playedWith
Map of how many games the player has played with each of the other players. This is called when “Shuffle” mode is enabled in the lobby, to ensure all players have an even amount of playtime.
player.[player id].lobby.music
Flag for whether the music has been turned on or off in the lobby.
player.[player id].lobby.sound
Flag for whether the sound has been turned on or off in the lobby.
SendAction("start")
This action should initialize and start the game. In order for it to work correctly, you need to register an action listener for ‘start’.
Since the Lobby is built into the Aug file, it is automatically added to the game once the Aug has been inserted into the project. The following listeners and actions need to be wired up:
The listeners are wired into the Lua, and therefore you will only need to handle Actions.
Since the lobby is built into the Aug file, when importing your Aug to your Tiny project, you will automatically be importing the lobby. From there, just make sure that everything within the lobby is still working as expected, otherwise there will be errors.
Start Button:
TableRealmsTiny.Actions.RegisterAction("start", => () {
// Set the page, or write the game logic, etc.
});
TODO:
Lobby:
| Object for Event | Condition | Parameters | Object for Action | Action | Parameters |
|---|---|---|---|---|---|
| Table Realms | Action executed named | “start” | Table Realms | send command | “gameStarted”=“” |
| Table Realms | Command Received named | “gameStarted” | TableRealms | Set String | “page”=“Game” |
| System | go to layout | “How To Play” | |||
| Browser | log in console | “The host has started the game” |
The last row in the table is not necessary for full execution of the lobby, but it does help with debugging!
Note: Always remember to test your systems to make sure they’re working correctly!
Testing the lobby system is slightly different to testing a game. Using the export feature, export your project to TR Testing Tool “Game” folder and open the “run.bat” file. Once the testing tool launches, scan the QR code that appears automatically, and check if the lobby loads on the device that scanned in. From there, to ensure that the lobby has loaded the QR code correctly, scan the QR that appears in the lobby of the host device with a secondary phone.