Skip to content
KCKingdoms Connected Scripting APIScripting guides and API
Global objectServer APIGenerated

Dice

const Dice: object

Defined in: server/api.d.ts:3163

Dice matches between two players, or a player and a server NPC, on the game’s own dice table.

Both players sit down at the dice table nearest them and play it as they would against an NPC, the other player’s body opposite. Every throw is dealt and every move checked by the server, by the game’s own scoring rules; badges and dice perks are off, so a match is decided by the dice and the decisions alone.

An Npc may hold the second seat. Its body sits opposite the player, its throws are dealt like anyone’s, and its decisions are the script’s: diceRoll says what it threw, Dice.move plays its move.

matchOf(player): number

The match a player is in.

number

NetworkID of the player to ask about.

number

The match id, or 0.

move(match, heldMask, pass): boolean

Plays the move of the NPC on the second seat, checked by the rules a player’s move is. Legal only while it is the NPC’s turn and its throw is on the table, so after a diceRoll naming it with reason rolled; calling it from that handler is supported. An accepted move raises diceMove and what follows from it. The NPC forfeits like a player when no move is accepted for three minutes.

number

Match ID.

number

Bit mask of the dice to set aside, bit 0 for die 0 through bit 5 for die 5, among those diceRoll reported in rolledMask. Every die in it must count towards a scoring combination.

boolean

True banks the turn after scoring the held dice, if any. False scores them, which needs at least one, and throws the rest.

boolean

False, with nothing changed, when the match has ended or has no NPC seat, it is not the NPC’s turn, or the move is not legal.

setNames(match, first, second): boolean

Changes both scoreboard labels on the next native scoreboard refresh. Empty restores a native label. Names allow at most 64 UTF-8 bytes and no control characters.

number

Match ID.

string

First seat label.

string

Second seat label.

boolean

False if the match has ended.

start(first, second, options?): number

Starts a match. Both players must stand together, within a few metres, at a dice table, and neither may be playing already. An NPC is held to the same: it must stand at the table with the player, in the same virtual world. Throws an Error saying why when it cannot start.

number

NetworkID of the player on the table’s first seat.

number

NetworkID of the player on the second seat, or of a living human Npc to seat there and play through Dice.move.

DiceMatchOptions

The target score. Optional.

number

The match id.

stop(match): boolean

Ends a match with nobody winning; both tables close.

number

The match to end.

boolean

False when it had already ended.

tables(virtualWorld?): DiceTableInfo[]

Lists the dice tables players in a virtual world can play at, and their seats: the level’s own, minus any a level edit took out of that world, and every table SmartObject.spawn or a World Builder export placed there or in the global world. Readiness and occupancy belong to the gamemode.

number

Optional virtual world whose tables to list; the global one when omitted.

DiceTableInfo[]

The tables, in no particular order.