Skip to content

Exports & events

Public API of Cuxial Domino: server exports to manage tables and events to follow matches.

Create and delete tables, find out where a player is seated and react to rounds, matches and bets from your own resources. The whole API is server side.

Server exports ​

GetTables ​

Returns every table.

lua
local tables = exports.cuxial_domino:GetTables()

Returns: table[], sorted by id. Each entry is a table summary:

FieldTypeDescription
idnumberTable id.
namestring | nilName given to the table.
postable{ x, y, z }.
headingnumberHeading of the table.
maxPlayersnumber1 to 4.
teamModebooleantrue on 4 player team tables.
tableModelstringModel of the table.
scoreModestring'classic' or 'fives'.
betMin, betMaxnumber | nilBet limits of the table. nil uses the global limits.
seatednumberPlayers seated right now.
inGamebooleantrue while a round is being played.
lua
for _, t in ipairs(exports.cuxial_domino:GetTables()) do
    print(t.id, t.name, t.seated, t.inGame)
end

GetTable ​

Returns the summary of one table.

lua
local tbl = exports.cuxial_domino:GetTable(id)
ParameterTypeDescription
idnumberTable id.

Returns: a table summary, or nil when the table does not exist.

lua
local tbl = exports.cuxial_domino:GetTable(3)
if tbl and not tbl.inGame then print('Table 3 is free') end

CreateTable ​

Creates a table and saves it in the database.

lua
local id, err = exports.cuxial_domino:CreateTable(data)
ParameterTypeDescription
data.postable{ x, y, z }. Required. Use the coordinates of a player standing on the spot: the table is placed one metre below z.
data.headingnumberHeading. 0.0 by default.
data.maxPlayersnumber1 to 4. 4 by default.
data.teamModebooleanTeams. Only applies with maxPlayers = 4.
data.stylestring'luxury', 'wood' or 'classic'. 'luxury' by default.
data.tableModelstringA model name. When given, it replaces style.
data.scoreModestring'classic' or 'fives'. 'classic' by default.
data.namestringName of the table. Cut at 60 characters.
data.betMin, data.betMaxnumberBet limits. Both are needed; with only one, the table uses the global limits.

Returns: the id of the new table, or nil and a reason. The reason is 'err_too_close' when another table is closer than table.minDistanceBetween, and 'err_table_not_found' when data or data.pos is missing.

lua
local id, err = exports.cuxial_domino:CreateTable({
    pos = { x = 195.0, y = -934.0, z = 30.7 },
    heading = 90.0,
    maxPlayers = 4,
    teamMode = true,
    style = 'wood',
    scoreMode = 'classic',
    name = 'Main square',
    betMin = 100,
    betMax = 5000,
})
if not id then print('Could not create the table: ' .. tostring(err)) end

DeleteTable ​

Deletes a table. Seated players are stood up and any bet already charged is returned.

lua
local ok = exports.cuxial_domino:DeleteTable(id)
ParameterTypeDescription
idnumberTable id.

Returns: boolean. false when the table does not exist.

lua
exports.cuxial_domino:DeleteTable(3)

GetPlayerTable ​

Returns where a player is seated.

lua
local tableId, seat = exports.cuxial_domino:GetPlayerTable(source)
ParameterTypeDescription
sourcenumberServer id of the player.

Returns: the table id and the seat number (1 to 4), or nil when the player is not seated.

lua
local tableId, seat = exports.cuxial_domino:GetPlayerTable(source)
if tableId then print(('Seated at table %d, seat %d'):format(tableId, seat)) end

IsSeated ​

Tells whether a player is seated at a table.

lua
local seated = exports.cuxial_domino:IsSeated(source)

Returns: boolean.

lua
if exports.cuxial_domino:IsSeated(source) then return end

on ​

Registers a function for one of the events listed below.

lua
local handle = exports.cuxial_domino:on(event, fn)
ParameterTypeDescription
eventstringEvent name without prefix, for example 'matchFinished'.
fnfunctionReceives the payload of the event.

Returns: a numeric handle, or nil when the arguments are not valid.

lua
local handle = exports.cuxial_domino:on('matchFinished', function(payload)
    print(('Table %d: seat %s won'):format(payload.tableId, tostring(payload.winnerSeat)))
end)

off ​

Removes a function registered with on.

lua
local removed = exports.cuxial_domino:off(handle)

Returns: boolean.

lua
exports.cuxial_domino:off(handle)

Server events ​

Every event is also triggered as a local server event named cuxial_domino:<event>. This is the simplest way to listen:

lua
AddEventHandler('cuxial_domino:betPaid', function(payload)
    print(('Table %d paid a pot of $%d'):format(payload.tableId, payload.total))
end)
EventPayloadWhen
tableCreated{ id, table, by }A table is created. table is its summary. by is the server id of the staff member, or nil when created by export.
tableRemoved{ id, by }A table is deleted.
playerSeated{ tableId, seat, source }A player sits down.
playerLeft{ tableId, seat, source, reason }A player leaves the table.
roundStarted{ tableId, seats, scoreMode }A round starts. seats is the list of seats playing, AI included.
tilePlayed{ tableId, seat, tile, side }A tile is placed, by a player or by the AI. tile is { a, b }.
bonus{ tableId, seat, points, kind }A classic match bonus is scored.
roundEnded{ tableId, winnerSeat, reason }A round ends. winnerSeat can be nil.
matchFinished{ tableId, winnerSeat, scores }A match ends. scores maps each seat to its points.
betPaid{ tableId, winnerSeat, total }The pot is paid to the winner. total is the whole pot.

Values ​

FieldValues
playerLeft.reason'left' (by choice), 'disconnected', 'inactive' (turns ran out)
tilePlayed.side'start', 'left', 'right'; in All Fives also 'top' and 'bottom'
bonus.kind'round_pass', 'opening_pass', 'capicua'
roundEnded.reason'domino' (a player went out), 'blocked', 'fives_target' and 'bonus_target' (target reached during the round), 'player_left' (round cancelled), 'last_standing', 'solo_left', 'no_players'

Seats are numbered 1 to 4. 2 player tables use seats 1 and 3. On 1 player tables the player is seat 1 and the AI is seat 2. In team tables, seats 1 and 3 play against 2 and 4.

Client ​

Cuxial Domino has no client exports or public client events.

© Cuxial