Provides the name of the last action that was called
Provides the value of the last action that was called into the model
Provides the name of the last command that was received
Provides the string value of the last command that was received by the device
Provides the name of the last model key that was changed
Provides the ID of the last player that joined
Provides the ID of the last player that left
Used as an expression to set the URL for the game’s QR code, when setting the image for a Sprite Object from a URL.
Gets the ID of the device on which a specific instance of the game is running
This allows you to receive the numerical value for a specific key in the model
Provides the ID of a particularly numbered player. Note, the order of thi list might vary between games.
Gets the number of players connected to the current Table Realms session. Can be used to trigger certain threshold actions, such as enabling or disabling context sensitive buttons.
This allows you to receive the string value for a specific key in the model
The different options available under “Context” can be used both as conditions and as identifiers. Using each of the options determines which mode the game is running as, and whether the instance of the game is currently running as a client or a host.
The context can then be used as a trigger to fire various events. An example of this would be checking whether the game is running in P2P mode, in which case, the QR sprite will be rendered invisible.
It is important to wrap everything in the context options of “is this instance a client” or “is this instance a host”. This will allow the P2 architecture model to be followed correctly, with anything that influences the outcome of the game being handled by the host. The different context options available are as follows:
This returns true if the game is running in P2P mode.
This returns true if the game is running in Embedded mode
This returns true if the game is running in Console mode
This returns true if the device is running as a client. Always true for all mobile devices when running in console mode.
This returns true if the device is running as the host. Always true for the console when console mode is being run.
True when the QR code data is ready to be loaded into a URL. Can be used as a condition to populate the QR code image, if there is no Lobby system being used.
The P3P model might seem like it requires less planning upfront, but in reality the reverse is true. When using the P3 architecture in Construct, a device needs to take responsibility for synchronisations. What this means is that some data needs to “belong” to the host, and some data needs to “belong” to the client(s). In this case, they should only be able to set model data from a single source. If model data is set concurrently from multiple sources, the devices will be in an asynchronous state, thereby causing a Table Realms crash.
The above point is important to remember since Table Realms does not enforce ownership of model data. In P3P, the client has the ability change any data. Ideally the client should only ever change the client’s information or data that is specificly meant to be changed by the client. A developer could choose to identify client owned information any way they want, but a good practice would be to use the device ID to do so. Note the inclusion of device id to the public key in the below event blocks. The “getDeviceId” function will only return the embedded device’s ID. Ensure that you use an “are we embedded” check when using getDeviceId, because this only works in embedded.
| Object for Event | Condition | Parameters | Object for Action | Action | Parameters |
|---|---|---|---|---|---|
| TableRealms | Are we embedded | TableRealms | Set Double | “publicDataKeyNumber.” & TableRealms.GetDeviceID=20 | |
| -> System | On start of layout | TableRealms | Set String | “publicDataKey.” & TableRealms.GetDeviceId=“This is data that was set privately by device id ” & TableRealms.GetDeviceId | |
| -> System | On start of layout | TableRealms | Set String | “publicDataKeyNumber.” & TableRealms.GetDeviceID=20 |
The following conditions are used when determining whether to fire triggers for events:
This trigger is fired when any action is executed.
This trigger is fired when a specific action being executed. You can specify which action by entering the name of the action being executed in the dialog box that appears.
This trigger is fired when any command is received by the client or host device.
This trigger is fired when a specific command is received by the device. You can specify which command to listen for by entering the name of the command being sent in the dialog box that appears.
This trigger is fired when there is a change to any value in the model.
This trigger is fired when there is a change in the model value linked to a specific key. This is specified by entering the name of the key whose value you want to track in the dialog box that appears.
This trigger is fired when a player joins the session.
This trigger is fired when a player leaves the session.
This trigger is executed when Table Realms has started and is ready for use.
Used by the host to distribute commands to the peers/clients. The command being sent needs a specific name and string parameter.
This allows you to set the numerical value for a specific key in the model
This allows you to set the string value for a specific key in the model