Dice
constDice: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.
Type Declaration
Section titled “Type Declaration”matchOf()
Section titled “matchOf()”matchOf(
player):number
The match a player is in.
Parameters
Section titled “Parameters”player
Section titled “player”number
NetworkID of the player to ask about.
Returns
Section titled “Returns”number
The match id, or 0.
move()
Section titled “move()”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.
Parameters
Section titled “Parameters”number
Match ID.
heldMask
Section titled “heldMask”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.
Returns
Section titled “Returns”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()
Section titled “setNames()”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.
Parameters
Section titled “Parameters”number
Match ID.
string
First seat label.
second
Section titled “second”string
Second seat label.
Returns
Section titled “Returns”boolean
False if the match has ended.
start()
Section titled “start()”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.
Parameters
Section titled “Parameters”number
NetworkID of the player on the table’s first seat.
second
Section titled “second”number
NetworkID of the player on the second seat, or of a living human Npc to seat there and play through Dice.move.
options?
Section titled “options?”The target score. Optional.
Returns
Section titled “Returns”number
The match id.
stop()
Section titled “stop()”stop(
match):boolean
Ends a match with nobody winning; both tables close.
Parameters
Section titled “Parameters”number
The match to end.
Returns
Section titled “Returns”boolean
False when it had already ended.
tables()
Section titled “tables()”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.
Parameters
Section titled “Parameters”virtualWorld?
Section titled “virtualWorld?”number
Optional virtual world whose tables to list; the global one when omitted.
Returns
Section titled “Returns”The tables, in no particular order.