Object

All pieces in the game are an Object. Once you have a reference to an Object you can call these functions like this: obj.getPosition(). You can get a reference multiple ways: using the self property on an Object scripts, using a GUID with getObjectFromGUID(), or as a return type from a function like takeObject().

The Global Script can be referenced by a special keyword Global. The Global reference is used only for functions getting or setting variables on the Global Script or for specifying the owner of a function in callbacks.

Member Variables

Type Variable Name Description
float angular_drag The Object’s angular drag.
bool auto_raise Should this Object automatically raise above other Objects when held?
float bounciness The Object’s bounciness.
Clock Clock If this Object is a Digital Clock, this member variable will be a reference to the Clock class attached to this Object, otherwise this value will be nil. Read only.
Counter Counter If this Object is a Counter, this member variable will be a reference to the Counter class attached to this Object, otherwise this value will be nil. Read only.
float drag The Object’s drag.
float dynamic_friction The Object’s dynamic friction.
string guid The Object’s guid. This is the same as the getGUID function. Read only.
string held_by_color The color of the Player currently holding the Object. Will be nil if the Object is not being held by anyone. Read only.
bool interactable Can players interact with this Object? If false, only Lua Scripts can interact with this Object.
float mass The Object’s mass.
string name The Object’s formated name or nickname if applicable. Read only.
bool resting Returns true if this Object is not moving. Read only.
RPGFigurine RPGFigurine If this Object is an RPGFigurine, this member variable will be a reference to the RPGFigurine class attached to this Object, otherwise this value will be nil. Read only.
string script_code Returns the Lua script on the Object.
string script_state Returns the saved Lua script state on the Object. See onSave().
float static_friction The Object’s static friction.
bool sticky Should Objects on top of this Object stick to this Object when this Object is picked up?
string tag The tag of the Object representing its type. Read only.
bool tooltip Should Object show tooltips when hovering over it.
TextTool TextTool If this Object is a TextTool, this member variable will be a reference to the TextTool class attached to this Object, otherwise this value will be nil. Read only.
bool use_gravity Does gravity affect this Object?
bool use_grid Should this Object snap to grid points?
bool use_snap_points Should this Object snap to snap points?

Object Properties

Return Value Function Name Description
string getDescription() Gets the description for this Object.
string getGUID() Returns the GUID that belongs to this Object.
string getLuaScript() Gets the Lua script for this Object.
string getName() Returns the nickname for this Object.
Table getTable( string table_name ) Gets a Lua Table for this Object.
variable getVar( string variable_name ) Gets a Lua variable for this Object. Will result in an error if you try to get a Table variable. Use getTable function for getting a Table from the Object.
bool setDescription( string description ) Sets the description for this Object.
bool setLuaScript( string script ) Sets the Lua script for this Object. Only useful in very rare cases right when this object is spawned. Once the Lua interpreter reads the Lua script, it will not care about this again. Setting this variable after its been read will do nothing.
bool setName( string nickname ) Sets the nickname for this Object.
bool setTable( string table_name, Table table ) Sets a Lua Table for this Object.
bool setVar( string variable_name, variable value ) Sets a Lua variable for this Object. Will result in an error if you try to set a Table variable. Use setTable function for setting a Table from the Object.

Object Transform Properties

Return Value Function Name Description
bool addForce( Table force_vector{float x, float y, float z}, int force_type ) Adds a force vector to the Object. The force type is optional and defaults to Impulse.

Force Type Value
Constant Force (uses mass) 1
Acceleration (ignores mass) 2
Impulse (uses mass) 3
Velocity Change (ignores mass) 4
bool addTorque( Table torque_vector{float x, float y, float z}, int force_type ) Adds a torque vector to the Object. The force type is optional and defaults to Impulse.

Force Type Value
Constant Force (uses mass) 1
Acceleration (ignores mass) 2
Impulse (uses mass) 3
Velocity Change (ignores mass) 4
bool flip() Flips this Object.
Table getAngularVelocity() Returns the current angular velocity vector of the Object. The angular velocity values in the returned table are keyed as Table[‘x’], Table[‘y’], and Table[‘z’].
Table getPosition() Gets the position for this Object. The position values in the returned table are keyed as Table[‘x’], Table[‘y’], and Table[‘z’].
Table getRotation() Gets the rotation of this Object in degrees. The rotation values in the returned table are keyed as Table[‘x’], Table[‘y’], and Table[‘z’].
Table getScale() Gets the scale for this Object. The scale values in the returned table are keyed as Table[‘x’], Table[‘y’], and Table[‘z’].
Table getVelocity() Returns the current velocity vector of the Object. The velocity values in the returned table are keyed as Table[‘x’], Table[‘y’], and Table[‘z’].
bool isSmoothMoving() Is the object smoothly moving from our smooth functions.
bool rotate( {float x, float y, float z} ) Smoothly rotates this Object with the given offset in degrees, i.e. rotate Object 90 degrees in the x direction from its current orientation.
bool scale( {float x, float y, float z} ) Scales this Object by the given amount.
bool scale( float scale ) Scales this Object in all axes by the given amount.
bool setPosition( {float x, float y, float z} ) Sets the world space position for this Object.
bool setPositionSmooth( {float x, float y, float z}, bool Collide = false, bool Fast = false ) Smoothly moves this Object from its current position to a given world space position. If there is a collision the object will be instantly teleported to the location.
bool setRotation( {float x, float y, float z} ) Sets the rotation of this Object in degrees.
bool setRotationSmooth( {float x, float y, float z}, bool Collide = false, bool Fast = false ) Smoothly rotates this Object to the given orientation in degrees.
bool setScale( {float x, float y, float z} ) Sets the scale for this Object.
bool translate( {float x, float y, float z} ) Smoothly moves this Object from its current position to a given offset.

Material Properties

Return Value Function Name Description
Table getColorTint() Returns the color tint for this Object. The color values in the returned table are keyed as Table[‘r’], Table[‘g’], and Table[‘b’]. Color values are between 0 and 1.
bool setColorTint( {float r, float g, float b} ) Sets the color tint for this Object. Color values are between 0 and 1.

UI Functions

Return Value Function Name Description
bool clearButtons() Clears all 3D UI buttons on this Object.
bool createButton( Table parameters ) Creates a 3D UI button on this Object.

Parameters Table:


local button_parameters = {}
button_parameters.click_function = string function_name
button_parameters.function_owner = Object function_owner
button_parameters.label = string button_label –Optional
button_parameters.position = {float x, float y, float z} –Optional
button_parameters.rotation = {float x, float y, float z} –Optional
button_parameters.width = int width –Optional
button_parameters.height = int height –Optional
button_parameters.font_size = int font_size –Optional

A nil value for funtion_owner means the function lives on the Global script.
bool editButton( Table parameters ) Edits a 3D UI button on this Object based on its index.

Parameter Table:


local button_parameters = {}
button_parameters.index = int index
button_parameters.click_function = string function_name –Optional
button_parameters.function_owner = Object function_owner –Optional
button_parameters.label = string button_label –Optional
button_parameters.position = {float x, float y, float z} –Optional
button_parameters.rotation = {float x, float y, float z} –Optional
button_parameters.width = int width –Optional
button_parameters.height = int height –Optional
button_parameters.font_size = int font_size –Optional
Table getButtons() Gets a list of all the 3D UI buttons on this Object.

Returned Table:


table.index = int index –The index of this button as a child of the Object. Used for editing or removing this specific button.
table.click_function = string click_function
table.function_owner = Object function_owner
table.label = string label_text
table.position = Table position –{x, y, z}
table.rotation = Table rotation –{x, y, z}
table.width = int button_width
table.height = int button_height
table.font_size = int font_size
bool removeButton( int index ) Removes a 3D UI button from this Object by its index.

Object Functions

Return Value Function Name Description
variable call( string function_name, Table function_parameters ) Calls a Lua function owned by this Object and passes an optional Table as parameters to the function.
Object clone( Table parameters ) Copies and pastes this Object. Returns a reference to the newly spawned Object.

Parameters Table:

local params = {}
params.position = {float x, float y, float z} –Optional. Where to spawn the pasted Object. Defaults to {0, 3, 0}.
params.snap_to_grid = boolean snap_to_grid –Optional. Should the spawned Object snap to the grid if the grid is turned on? Defaults to false.
bool cut() Cuts this Object if it is a Deck or a Stack
bool dealToAll( int num_cards ) Deals a number of Cards from a this Deck to all seated players.
bool dealToColor( int num_cards, string player_color ) Deals a number of Cards from this Deck to a specific player.
Object dealToColorWithOffset( {float x, float y, float z}, bool flip, string player_color ) Deals a Card to a player with an offset from their hand. Set the offset to 0 to deal in their hand. Returns a reference to the dealt Card.
bool destruct() Destroys this Object. Mainly so you can call self.destruct().
Table getCustomObject() Returns the custom parameters on a Custom Object.

Returned Table
Key Type Description
image string Image URL for Custom Board, Custom Dice, Custom Figurine, Custom Tile, and Custom Token.
image_secondary string Secondary / Back Image URL for Custom Figurine or Custom Tile.
type int The number of sides of the Custom Dice, the shape of the Custom Tile, the type of Custom Mesh, or the type of Custom AssetBundle.
thickness float Thickness of the Custom Tile or Custom Token.
stackable bool Is this Custom Tile or Custom Token stackable?
merge_distance float The accuracy of the Custom Tile to it’s base image.
mesh string Mesh URL for the Custom Mesh.
diffuse string Diffuse image URL for the Custom Mesh.
normal string Normal image URL for the Custom Mesh.
collider string Collider URL for the Custom Mesh.
convex bool Is this Custom Mesh concave?
material int The material for the Custom Mesh or Custom AssetBundle.
specular_intensity float The specular intensity for the Custom Mesh.
specular_color Table The specular color for the Custom Mesh.
specular_sharpness float The specular sharpness for the Custom Mesh.
fresnel_strength float The fresnel strength for the Custom Mesh.
cast_shadows bool Does this Custom Mesh cast shadows?
assetbundle string AssetBundle URL for this Custom AssetBundle.
assetbundle_secondary string Secondary AssetBundle URL for this Custom AssetBundle.
bool getLock() Get the lock status of this object.
Table getObjects() Returns all the Objects inside of this container.

Object Returned Data
Scripting Zone Returns all Objects in the Zone.
Loot Bag Returns a Table with the keys “name”, “guid”, and “index”. Objects in Loot Bags are not living in the game. They’re serialized into a text format. To interact with or change an Object in a Loot Bag, it must first be taken out (which spawns it in the game). Objects in Loot Bags can be taken out of the Bag by the takeObject function by referencing its “index” or “guid”. It’s recommended to remove Objects by their GUIDs rather than their indices since the indices can change after one object was removed.
Deck Returns a Table of Tables of all of the Cards in the Deck. These are not references to the cards since the Cards are not instantiated until they are removed from the Deck.

Card Table:


table.index = int index
table.nickname = string nickname
table.description = string description
table.guid = string guid
table.lua_script = string lua_script

int getQuantity() Returns the number of Objects in a stack. Will return -1 if the object is not a stack.
int getStatesCount() Returns the number of States on this Object. Returns -1 if this Object does not have multiple States attached to it.
int getValue() Returns the value for this Object.

Object Value
Clock Returns the current stopwatch or timer value.
Counter Returns the value.
Dice Returns the face-up value.
Poker Chip Returns the face value.
Tablet Returns the URL.
bool highlightOn( {float r, float g, float b }, float duration –Optional.
)
Highlight this object with color for an optional duration. Color values are between 0 and 1.
bool highlightOff() Stop highlighting this object.
bool lock() Locks this Object.
bool reset() Resets this Object. Resetting a Deck brings all the Cards back into it. Resetting a Bag clears its contents (works for both Loot and Infinite Bags).
bool roll() Rolls this Object. Works on Dice and Coins.
bool setCustomObject( Table parameters ) Used to create a Custom Object. All custom types except for Custom Decks are supported. See here for information about the parameters for each type of Custom Object.
bool setLock( bool lock ) Set the lock status of an object.
Object setState( int state ) Sets the current State for this Object if it has multiple States attached to it and returns a reference to the new State. The old reference will be destroyed, so update your reference to this Object with the return value of the new State. Returns nil if this Object does not have multiple states attached to it.
bool setValue( variable value ) Sets the value for this Object.

Object Value
Clock Sets the timer value.
Counter Sets the value.
Dice Sets the face-up value.
Tablet Sets the URL.
bool shuffle() Shuffles this Object.
Objects this works on:
Deck
Loot Bag
Object shuffleStates() Shuffles the States on this Object if it has multiple States attached to it and returns a reference to the new State. The old reference will be destroyed, so update your reference to this Object with the return value of the new State. Returns nil if this Object does not have multiple states attached to it.
Object takeObject( Table parameters ) Takes an Object from this container (Loot Bag, Deck, and Infinite Bag), moves, and rotates it to the specified position and rotation. Returns a reference to the taken Object. Since executing the Lua scripts on the taken object and other initialization takes a few frames, any operations that need to be performed on this object immediately after it is taken from the container should be done in the callback function. The callback prevents needing to use a coroutine and yielding/waiting multiple frames. All of the parameters are optional and defers to default values if any of the lines are not included. If you want all of the default values, just pass in an empty table.

Parameters Table:


local params = {}
params.position = {float x, float y, float z} –Optional. Defaults to the container’s position + 2 in the x direction.
params.rotation = {float x, float y, float z} –Optional. Defaults to the container’s rotation.
params.callback = string callback_function_name –Optional.
params.callback_owner = Object callback_owner –Optional. Defaults to the container that the Object was taken from.
params.params = Table callback_parameters –Optional.
params.flip = boolean flip_object –Optional. Only used when taking Cards from a Deck.
params.guid = string guid –Optional. Only used when taking an Object from a Loot Bag by GUID.
params.index = int index –Optional. Used when taking an Object from a Loot Bag or a Card from a Deck by index.
params.top = bool take_from_top –Optional. Specifies whether to take a Card from the top or bottom of the Deck. Defaults to true, taking from the top of the Deck.

It’s recommended to remove Objects from Loot Bags by their GUIDs rather than their indices since the indices can change after one object was removed.
bool unlock() Unlocks this Object.