Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Card

A stack of cards. Also represents single cards as a stack of one card.

Hierarchy

Index

Properties

Methods

Properties

onCreated

onCreated: MulticastDelegate<(object: this) => void>

Called when the object is created (from the object library, loading a game, copy & paste, dragging from an infinite container or stack...)

param

The new object

onCustomAction

onCustomAction: MulticastDelegate<(object: this, player: Player, identifier: string) => void>

Called when a custom action defined through addCustomAction is executed.

param

The object on which the action is executed

param

The player that executed the action

param

The identifier of the executed action

onDestroyed

onDestroyed: MulticastDelegate<(object: this) => void>

Called when the object is destroyed

param

The destroyed object

onFlipUpright

onFlipUpright: MulticastDelegate<(object: this, player: Player) => void>

Called when the flip/upright action is executed on the object. This can happen while held or when a user presses the flip/upright button while the object is selected or highlighted. The event is triggered immediately when the action starts, so the object will not have flipped yet.

param

The object being flipped

param

The player that flipped the object

onGrab

onGrab: MulticastDelegate<(object: this, player: Player) => void>

Called when the object is picked up

param

The object being grabbed

param

The player that grabbed the object

onHit

onHit: MulticastDelegate<(object: this, otherObject: GameObject | undefined, first: boolean, impactPoint: Vector | [x: number, y: number, z: number], impulse: Vector | [x: number, y: number, z: number]) => void>

Called when the object is hit by another object or hits another object. Gets called for both objects involved in a collision. Only called for collisions that cause an impact sound to be played.

param

The first object in the collision

param

The second object in the collision. Can be undefined if an object collides with scenery.

param

True if this call is the first of the two calls made for each collision. Check this parameter if you only want to react once to a collision but both colliding objects can have the onHit event defined.

param

The position at which the two objects collided

param

Direction and magnitude of the impulse generated by the collision on the first object. Invert to get impulse on the second object.

onInserted

onInserted: MulticastDelegate<(card: this, insertedCard: Card, position: number, player: Player | undefined) => void>

Called after a card (or stack of cards) is added to this card. Not called immediately when a player drops a card, but when the animation finishes.

param

The target card, with the new card already inserted.

param

The newly inserted card. Only used for information about what was inserted, this object gets deleted immediately after the call ends.

param

The position in the stack at which the card was inserted. 0 when dropped to the front, number of cards in the stack before inserting when dropped to the back

param

The player who added a card. undefined if the card was added through scripting.

onMovementStopped

onMovementStopped: MulticastDelegate<(object: this) => void>

Called when the object comes to rest. For ground objects or when the session is set to locked physics, the object has been locked right before this event is triggered.

onNumberAction

onNumberAction: MulticastDelegate<(object: this, player: Player, number: number) => void>

Called when a player executes a number action on the object (by highlighting or selecting it and pressing number keys). Will be called even if the object has a defined behavior for number actions (like dice or multistate objects), after any object defined behavior.

param

The object on which the action is executed

param

The player that executed the action

param

The number pressed by the player

onPrimaryAction

onPrimaryAction: MulticastDelegate<(object: this, player: Player) => void>

Called a player executes the primary action on an object by pressing the respective button (default mapping "R"). Will be called even if the object has a defined behavior for primary actions (like dice or multistate objects), after any object defined primary action.

param

The object on which the action is executed

param

The player that executed the action

onReleased

onReleased: MulticastDelegate<(object: this, player: Player, thrown: boolean, grabPosition: Vector | [x: number, y: number, z: number], grabRotation: Rotator | [pitch: number, yaw: number, roll: number]) => void>

Called when the object is released (but not reset). When the object is snapped, onSnapped or onSnappedToGrid are called in addition.

param

The object being released

param

The player that released the object

param

True if the object was thrown (released above a threshold velocity) instead of being dropped

param

The position where this object was when it was grabbed. Zero if it hasn't been grabbed (for example when it was dragged from the object library).

param

The rotation this object had when it was grabbed.

onRemoved

onRemoved: MulticastDelegate<(card: this, removedCard: Card, position: number, player: Player) => void>

Called after a card is removed from the stack by a player. This can happen when a player drags a card off the stack or the container explorer, when drawing or dealing cards, or when a player cuts/splits/divides the stack. In the last case, the removed card object may be a stack of cards.

param

The card stack from which the object is removed

param

The removed card (now grabbed by the player)

param

The position in the stack from which the card was removed. 0 when removed from the front, number of cards in the after removing when removed from the back

param

The player who removed the card

onReset

onReset: MulticastDelegate<(object: this, player: Player) => void>

Called when the object is reset to its position before being picked up.

param

The object being reset

param

The player that reset the object

onSecondaryAction

onSecondaryAction: MulticastDelegate<(object: this, player: Player) => void>

Called a player executes the secondary action on an object by pressing the respective button (default mapping "Ctrl+R"). Will be called even if the object has a defined behavior for primary actions (like card stacks or multistate objects), after any object defined primary action.

param

The object on which the action is executed

param

The player that executed the action

onSnapped

onSnapped: MulticastDelegate<(object: this, player: Player, snapPoint: SnapPoint, grabPosition: Vector | [x: number, y: number, z: number], grabRotation: Rotator | [pitch: number, yaw: number, roll: number]) => void>

Called when the object is snapped to a snap point on releasing. Not called when snapping to the global grid, in that case onSnappedToGrid is called instead.

param

The object being released

param

The player that released the object

param

The point that the object is moved to

param

The position where this object was when it was grabbed. Zero if it hasn't been grabbed (for example when it was dragged from the object library)

param

The rotation this object had when it was grabbed.

onSnappedTo

onSnappedTo: MulticastDelegate<(object: GameObject, player: Player, snapPoint: SnapPoint, grabPosition: Vector | [x: number, y: number, z: number], grabRotation: Rotator | [pitch: number, yaw: number, roll: number]) => void>

Called when another object is snapped to a snap point on this object. This event is triggered for the object with the target snap point, see GameObject.onSnapped for an event on the object that snaps.

param

The object being released

param

The player that released the object

param

The point that the object is moved to

param

The position where the released object was when it was grabbed. Zero if it hasn't been grabbed (for example when it was dragged from the object library)

param

The rotation the released object had when it was grabbed.

onSnappedToGrid

onSnappedToGrid: MulticastDelegate<(object: this, player: Player, grabPosition: Vector | [x: number, y: number, z: number], grabRotation: Rotator | [pitch: number, yaw: number, roll: number]) => void>

Called on releasing an object when the object is snapped to the global grid or because of the "Always Snap" setting in the session options.

param

The object being released

param

The player that released the object

param

The position where this object was when it was grabbed. Zero if it hasn't been grabbed (for example when it was dragged from the object library)

param

The rotation this object had when it was grabbed.

onTick

onTick: MulticastDelegate<(object: this, deltaTime: number) => void>

Called every tick.

param

The reference object

param

Duration of the previous tick

Methods

addCards

  • addCards(cards: Card, toFront?: boolean, offset?: number, animate?: boolean, flipped?: boolean): boolean
  • Add cards to the stack. Returns whether the cards have been added successfully. Will not succeed if the shape or size of the cards does not match, or if this card is in a card holder.

    Parameters

    • cards: Card

      Card (stack) to add to the stack

    • Optional toFront: boolean

      If true, add new cards to front of the stack. Default: false.

    • Optional offset: number

      Number of cards to skip at the back (or front when toFront is true) before adding cards. Default: 0

    • Optional animate: boolean

      If true, play card drop sound and animate the new cards flying to the stack. The animation takes some time, so the new cards aren't added to the stack instantly. If you need to react when the cards are added, you can use onInserted. Default: false.

    • Optional flipped: boolean

      If true, add the cards flipped compared to the front card of the stack. Only has an effect if all involved cards allow flipping in stacks. Default: false.

    Returns boolean

addCustomAction

  • addCustomAction(name: string, tooltip?: string, identifier?: string): void
  • Add a custom action that appears in the context menu of the object.

    Parameters

    • name: string

      The name for the action in the context menu

    • Optional tooltip: string

      The tooltip text to show for the custom action

    • Optional identifier: string

      An identifier passed to the onCustomAction event if you don't want to use the action name to identify what action is executed. If empty, the action name is used as identifier.

    Returns void

addDrawingLine

  • Add a drawn line to the object. Lines are geometry and can increase the size of the object returned by getSize and getExtent. Returns whether the line was added successfully. It can't be added if no table exists, if the DrawingLine is invalid, or if there are already too many lines drawn on the table and the new line would go beyond the limit.

    Parameters

    Returns boolean

addUI

  • Attach a new UI element object to this object.

    Parameters

    • element: UIElement

      The UI element to attach

    Returns number

    • The index of the attached UI element

applyAngularImpulse

  • applyAngularImpulse(impulse: Vector | [x: number, y: number, z: number], useMass?: boolean): void
  • Apply a torque to the object. Works as an instant change of angular velocity.

    Parameters

    • impulse: Vector | [x: number, y: number, z: number]

      The axis of rotation and magnitude of the impulse to apply in kg*cm^2/s.

    • Optional useMass: boolean

      If false (default), ignore the mass of the object and apply the force directly as change of angular velocity in cm^2/s.

    Returns void

applyForce

  • applyForce(force: Vector | [x: number, y: number, z: number], useMass?: boolean): void
  • Apply a force to the object. Works like a "thruster" and should be called every tick for the duration of the force.

    Parameters

    • force: Vector | [x: number, y: number, z: number]

      The direction and magnitude of the force to apply in kg*cm/s^2.

    • Optional useMass: boolean

      If false (default), ignore the mass of the object and apply the force directly as change of acceleration in cm/s^2.

    Returns void

applyForceAtPosition

  • applyForceAtPosition(force: Vector | [x: number, y: number, z: number], position: Vector | [x: number, y: number, z: number]): void
  • Apply a force to the object. Works like a "thruster" and should be called every tick for the duration of the force.

    Parameters

    • force: Vector | [x: number, y: number, z: number]

      The direction and magnitude of the force to apply in kg*cm\s^2.

    • position: Vector | [x: number, y: number, z: number]

      The position where to apply the force, relative to the object origin. If this is not equal to the center of mass, the force will create angular acceleration.

    Returns void

applyImpulse

  • applyImpulse(impulse: Vector | [x: number, y: number, z: number], useMass?: boolean): void
  • Apply an impulse to the object. Works as an instant change of velocity.

    Parameters

    • impulse: Vector | [x: number, y: number, z: number]

      The direction and magnitude of the impulse to apply in kg*cm/s.

    • Optional useMass: boolean

      If false (default), ignore the mass of the object and apply the impulse directly as change of velocity in cm/s.

    Returns void

applyImpulseAtPosition

  • applyImpulseAtPosition(impulse: Vector | [x: number, y: number, z: number], position: Vector | [x: number, y: number, z: number]): void
  • Apply an impulse to the object. Works as an instant change of velocity.

    Parameters

    • impulse: Vector | [x: number, y: number, z: number]

      The direction and magnitude of the impulse to apply in kg*cm/s

    • position: Vector | [x: number, y: number, z: number]

      The position where to apply the impulse, relative to the object origin. If this is not equal to the center of mass, the force will create angular velocity.

    Returns void

applyTorque

  • applyTorque(torque: Vector | [x: number, y: number, z: number], useMass?: boolean): void
  • Apply a torque to the object. Works like a "thruster" and should be called every tick for the duration of the torque.

    Parameters

    • torque: Vector | [x: number, y: number, z: number]

      The axis of rotation and magnitude of the torque to apply in kg*cm^2/s^2.

    • Optional useMass: boolean

      If false (default), ignore the mass of the object and apply the force directly as change of angular acceleration in cm^2/s^2.

    Returns void

areLightsOn

  • areLightsOn(): boolean

attachUI

canAddCards

  • canAddCards(cards: Card): boolean
  • Returns if the given cards can be added to the stack. Will return false if the shape or size of the cards does not match, or if this card is in a card holder, for example.

    Parameters

    • cards: Card

      Card (stack) to check for adding to the stack

    Returns boolean

createSwitcher

  • Create and return a new switcher with this object as the first (and active) state

    Parameters

    • objects: GameObject[]

      The other objects to include in the switcher. At least one element is needed because switchers are only valid with at least two objects.

    • Optional showAnimation: boolean

    Returns Switcher

deal

  • deal(count?: number, slots?: number[], faceDown?: boolean, dealToAllHolders?: boolean): void
  • Deal a number of cards from this stack to all hands

    Parameters

    • Optional count: number

      The number of cards to deal to each card holder. Defaults to 1.

    • Optional slots: number[]

      A set of slots to identify which players receive cards. If empty, all players will receive cards.

    • Optional faceDown: boolean

      When true, cards are dealt with their faces down. Default: false

    • Optional dealToAllHolders: boolean

      When false, only card holders that are the primary holder of an active player will receive cards. When true, all card holders (except those without an owner slot) will receive a card. Default: false

    Returns void

destroy

  • destroy(): void

divide

  • divide(numCards: number): Card[]
  • Divide the card stack into a number of smaller stacks, each with the given number of cards. One of the stacks will be smaller if the current stack size is not divisible by the number of cards.

    Parameters

    • numCards: number

      Number of cards in each stack

    Returns Card[]

    • The newly created stacks, starting with the stack at the bottom as the first item

flipOrUpright

  • flipOrUpright(): void
  • Flip the object or rotate it to its default orientation, depending on the object. Uses animation and physics. Calling this does the same thing as a player pressing the flip/upright key for highlighted or selected objects. Cards in holders are also flipped, but held objects are not affected.

    Returns void

freeze

  • freeze(): void
  • Immediately freeze the object and set its type to ground if it is currently not a ground object.

    Returns void

getAllCardDetails

getAllSnapPoints

getAngularVelocity

getAttachedUIs

getBounciness

  • getBounciness(): number

getCardDetails

  • Return details for a card in the stack. Return undefined for an invalid index.

    Parameters

    • index: number

      The index in the stack for which to retrieve details. Index 0 is the front card of which the face is visible.

    Returns CardDetails | undefined

  • Return details for the first card in the stack.

    Returns CardDetails

getCenterOfMass

getContainer

getDensity

  • getDensity(): number

getDescription

  • getDescription(): string

getDrawingLines

getExtent

  • getExtent(currentRotation: boolean, includeGeometry: boolean): Vector
  • Get the object extent: half-size of an axis-aligned bounding box encompassing the object. Adding this vector to the position returned by getExtentCenter gives a corner of the bounding box.

    Parameters

    • currentRotation: boolean

      If true, return the extent of an axis-aligned bounding box around the object at its current rotation. If false, return for the default rotation.

    • includeGeometry: boolean

      Determines whether visible geometry is included in the extent. If false, only colliders are used when determining the extent.

    Returns Vector

getExtentCenter

  • getExtentCenter(currentRotation: boolean, includeGeometry: boolean): Vector
  • Get the center of the object extent: an axis-aligned bounding box encompassing the object. This will often be the same position as returned by getPosition, but will differ for objects with their physical center not at their volume center.

    Parameters

    • currentRotation: boolean

      If true, return the extent of an axis-aligned bounding box around the object at its current rotation. If false, return for the default rotation.

      • @param {boolean} includeGeometry - Determines whether visible geometry is included in the extent. If false, only colliders are used when determining the extent.
    • includeGeometry: boolean

    Returns Vector

getFriction

  • getFriction(): number

getGroupId

  • getGroupId(): number
  • Return the object's group id. Objects with the same group id are always picked up together. Returns -1 if the object is not part of a group.

    Returns number

getHolder

getId

  • getId(): string

getLinearVelocity

getMass

  • getMass(): number

getMetallic

  • getMetallic(): number

getName

  • getName(): string

getObjectType

  • getObjectType(): number

getOwningPlayer

  • getOwningPlayer(): Player | undefined

getOwningPlayerSlot

  • getOwningPlayerSlot(): number

getPackageId

  • getPackageId(): string

getPackageName

  • getPackageName(): string

getPosition

getPrimaryColor

  • getPrimaryColor(): Color

getRotation

getRoughness

  • getRoughness(): number
  • Return the object's roughness value. Lower roughness makes the object more shiny.

    Returns number

getSavedData

  • getSavedData(key: string): string

getScale

getScriptFilename

  • getScriptFilename(): string
  • Return the filename of the object's script. Returns an empty string if no script is set for the object.

    Returns string

getScriptPackageId

  • getScriptPackageId(): string
  • Return the package id of the object's script. Returns an empty string if no script is set for the object.

    Returns string

getSecondaryColor

  • getSecondaryColor(): Color

getSize

  • Get the size of the object in cm. This is the same size that is shown in the editor and the coordinates window, it doesn't change when the object is rotated. If you are looking to calculate the borders of the object, use getExtent instead.

    Returns Vector

getSnapPoint

  • getSnapPoint(index: number): SnapPoint | undefined

getSnappedToPoint

  • Return the snap point that the object is snapped to (or more precisely, the snap point that the object would snap to if it was snapped now). Return undefined if the object is not snapped to any points. Objects are not bound to snap points when they are snapped, only their position is adjusted. Therefore, this method is not guaranteed to work correctly. It uses the same mechanism that regular snapping uses to determine where an object should snap. This could fail for snap points that are high above a surface: the object may have fallen or snapped too far below the snap point.

    Returns SnapPoint | undefined

getStackSize

  • getStackSize(): number
  • Get the number of cards in the stack. A single card has a stack size of 1.

    Returns number

getSurfaceType

  • getSurfaceType(): string

getSwitcher

  • Get the switcher that contains this object. Returns undefined if the object is not part of a switcher

    Returns Switcher | undefined

getTags

  • getTags(): string[]

getTemplateId

  • getTemplateId(): string

getTemplateMetadata

  • getTemplateMetadata(): string

getTemplateName

  • getTemplateName(): string

getUIs

isFaceUp

  • isFaceUp(): boolean
  • Return whether the front face of the card currently showing (pointing upwards)

    Returns boolean

isHeld

  • isHeld(): boolean

isInHand

  • isInHand(): boolean
  • Return whether the card is currently in the hand (primary holder) of a player

    Returns boolean

isInHolder

  • isInHolder(): boolean
  • Return whether the card is currently in a card holder

    Returns boolean

isSimulatingPhysics

  • isSimulatingPhysics(): boolean
  • Return whether the object is currently simulating physics. If false, the object is stuck in place and won't move when hit by other objects. This can happen with stationary ground mode objects or with locked physics sessions.

    Returns boolean

isSnappingAllowed

  • isSnappingAllowed(): boolean

isValid

  • isValid(): boolean
  • Return whether the object is valid. An object becomes invalid after it has been destroyed

    Returns boolean

localPositionToWorld

  • localPositionToWorld(position: Vector | [x: number, y: number, z: number]): Vector
  • Transform an object position to a world position

    Parameters

    • position: Vector | [x: number, y: number, z: number]

      The position relative to the object center to transform to world space

    Returns Vector

localRotationToWorld

  • localRotationToWorld(rotation: Rotator | [pitch: number, yaw: number, roll: number]): Rotator
  • Transform an object rotation to a world rotation

    Parameters

    • rotation: Rotator | [pitch: number, yaw: number, roll: number]

      The rotation relative to the object center to transform to world space

    Returns Rotator

moveCardInStack

  • moveCardInStack(from: number, to: number): void
  • Move a card to a new position within the stack

    Parameters

    • from: number

      The current index of the card to be moved

    • to: number

      The new index of the card to be moved

    Returns void

release

  • release(): void
  • Ensure that no player is holding this object. If any player is currently holding the object, it will fall down. Some GameObject methods (like setting position or applying physical force) don't have an effect or do not work properly while a player is holding the object.

    Returns void

removeCustomAction

  • removeCustomAction(identifier: string): void
  • Remove a custom action by identifier or name.

    Parameters

    • identifier: string

      The identifier or name of the action to remove

    Returns void

removeDrawingLine

  • removeDrawingLine(index: number): void

removeDrawingLineObject

removeFromHolder

  • removeFromHolder(): void
  • Remove card from its current card holder. Does change the position of the card and does nothing if the card is not currently in a card holder. While cards are in card holders, their physical properties can't be changed and no physical forces or impulses can be applied to them.

    Returns void

removeUI

  • removeUI(index: number): void
  • Remove attached UI element at the given index.

    Parameters

    • index: number

      The index of the UI element to remove

    Returns void

removeUIElement

  • Remove an attached UI element. Does not have any effect if the passed UI element is not attached to the object.

    Parameters

    Returns void

setAngularVelocity

  • setAngularVelocity(velocity: Rotator | [pitch: number, yaw: number, roll: number]): void
  • Set the object's angular (rotational) velocity in degrees/second. Note that setting velocity directly can lead make the physics simulation unstable, you should prefer to apply impulse, torque, or force to the object.

    Parameters

    • velocity: Rotator | [pitch: number, yaw: number, roll: number]

      The new angular velocity

    Returns void

setBounciness

  • setBounciness(bounciness: number): void
  • Set the object's bounciness value

    Parameters

    • bounciness: number

      The new bounciness value, from 0 to 1

    Returns void

setCardIndexAt

  • setCardIndexAt(cardIndex: number, index?: number): void
  • Set the card index of a card in the stack. This index corresponds to CardDetails.index, changing it will show a different card face.

    Parameters

    • cardIndex: number

      The new card index. Only indices that are used in the template for the card (as defined in the editor) are allowed. Card index 0 corresponds to the upper left card on the card image.

    • Optional index: number

      The index in the stack for which to update the card index. Index 0 is the front card of which the face is visible. Default: 0

    Returns void

setDensity

  • setDensity(density: number): void
  • Set the object's density value

    Parameters

    • density: number

      The new density value

    Returns void

setDescription

  • setDescription(description: string): void
  • Set the object's description

    Parameters

    • description: string

      The new object description. Maximum length is 2000 characters. You can use the same BBCode tags as in the in-game notes or the RichText widget.

    Returns void

setFriction

  • setFriction(friction: number): void
  • Set the object's friction value

    Parameters

    • friction: number

      The new friction value, from 0 to 1

    Returns void

setGroupId

  • setGroupId(groupId: number): void
  • Set the object's group id. Objects with the same group id are always picked up together.

    Parameters

    • groupId: number

      The new group id. Set to -1 to remove the object from all groups.

    Returns void

setId

  • setId(iD: string): boolean
  • Set the object's unique id. Returns whether the id was changed successfully. Fails if the id is already used by another object.

    Parameters

    • iD: string

    Returns boolean

setInheritScript

  • setInheritScript(inherit: boolean): void
  • Set whether this card stack inherits its configured script to cards taken from it (by players or using scripting). By default, script inheritance is enabled. Note: This property is not saved in states.

    Parameters

    • inherit: boolean

    Returns void

setLinearVelocity

  • setLinearVelocity(velocity: Vector | [x: number, y: number, z: number]): void
  • Set the object's linear velocity in cm/second. Note that setting velocity directly can lead make the physics simulation unstable, you should prefer to apply impulse or force to the object.

    Parameters

    • velocity: Vector | [x: number, y: number, z: number]

      The new velocity

    Returns void

setMetallic

  • setMetallic(metallic: number): void
  • Set the object's metallic value

    Parameters

    • metallic: number

      The new metallic value, from 0 to 1

    Returns void

setName

  • setName(name: string): void
  • Set the object's user visible name

    Parameters

    • name: string

      The new name

    Returns void

setObjectType

  • setObjectType(type: number): void

setOwningPlayerSlot

  • setOwningPlayerSlot(slot: number): void
  • Set the player slot that owns the object. Set to -1 to remove owner.

    Parameters

    • slot: number

      The new owning player slot

    Returns void

setPosition

  • setPosition(position: Vector | [x: number, y: number, z: number], animationSpeed?: number): void
  • Set the object's position. Optionally show an animation of the object flying toward the new location. The animation is only visual, the physical location of the object is changed instantly. Does not have an effect if a player is currently holding the object.

    Parameters

    • position: Vector | [x: number, y: number, z: number]

      The new position

    • Optional animationSpeed: number

      If larger than 0, show animation. A value of 1 gives a reasonable, quick animation. Value range clamped to [0.1, 5.0]. Default: 0

    Returns void

setPrimaryColor

  • setPrimaryColor(color: Color | [r: number, g: number, b: number, a: number]): void
  • Set the object's primary color

    Parameters

    • color: Color | [r: number, g: number, b: number, a: number]

      The new primary color

    Returns void

setRotation

  • setRotation(rotation: Rotator | [pitch: number, yaw: number, roll: number], animationSpeed?: number): void
  • Set the object's rotation. Optionally show an animation of the object rotating toward the new orientation. The animation is only visual, the physical rotation of the object is changed instantly. Does not have an effect if a player is currently holding the object.

    Parameters

    • rotation: Rotator | [pitch: number, yaw: number, roll: number]

      The new rotation

    • Optional animationSpeed: number

      If larger than 0, show animation. A value of 1 gives a reasonable, quick animation. Value range clamped to [0.1, 5.0]. Default: 0

    Returns void

setRoughness

  • setRoughness(roughness: number): void
  • Set the object's roughness value. Lower roughness makes the object more shiny.

    Parameters

    • roughness: number

      The new roughness value, from 0 to 1

    Returns void

setSavedData

  • setSavedData(data: string, key: string): void
  • Set the data that will be stored in save game states. The data is available using getSavedData when the object script is run after loading a save state. Try to keep this data small and don't change it frequently, it needs to be sent over the network to all clients. A similar method exists for global saved data: GameWorld.setSavedData.
    If you want to use custom data that is not a string, you can encode it to JSON using JSON.stringify(), and then decode what you get from getSavedData using JSON.parse().

    Parameters

    • data: string

      Data to store, maximum length 1023 characters

    • key: string

    Returns void

setScale

  • setScale(scale: Vector | [x: number, y: number, z: number]): void
  • Set the object's scale instantly

    Parameters

    • scale: Vector | [x: number, y: number, z: number]

      The new scale

    Returns void

setScript

  • setScript(filename: string, packageId?: string): void
  • Set the object's script. The script will be executed immediately.

    Parameters

    • filename: string

      The filename of the script. Pass an empty string to remove the current script.

    • Optional packageId: string

      The id of the package that contains the script file (in the Scripts folder). Can usually be empty when used from scripts to use the same package that contains the script file, but you need to explicitly pass refPackageId for the current package or a package id when you use it in a callback. You can find package ids in the manifest.json file in package folders. Usually you won't use this parameter, unless you have a specific reason to set a script from a different package than where the calling script is located.

    Returns void

setSecondaryColor

  • setSecondaryColor(color: Color | [r: number, g: number, b: number, a: number]): void
  • Set the object's secondary color

    Parameters

    • color: Color | [r: number, g: number, b: number, a: number]

      The new secondary color

    Returns void

setSnappingAllowed

  • setSnappingAllowed(allowed: boolean): void

setSurfaceType

  • setSurfaceType(surfaceType: string): void
  • Set surface type. Only affects sound effects when colliding with other objects.

    Parameters

    • surfaceType: string

    Returns void

setTags

  • setTags(tags: string[]): void
  • Set the list of tags for the object.

    Parameters

    • tags: string[]

    Returns void

setTextureOverrideURL

  • setTextureOverrideURL(url: string): void
  • Set the URL of the online texture override for all cards in this stack. When called for card stacks where all cards don't use a texture atlas (i.e. the whole image is used as the card front), the scale of the object is updated to reflect the correct aspect ratio of the new image after it has been loaded.

    Parameters

    • url: string

      URL to use

    Returns void

setTextureOverrideURLAt

  • setTextureOverrideURLAt(url: string, index?: number): void
  • Set the URL of the online texture override for a card in this stack.

    Parameters

    • url: string

      URL to use

    • Optional index: number

      The index in the stack for which to update the texture override. Index 0 is the front card of which the face is visible. Default: 0

    Returns void

setUI

  • setUI(index: number, element: UIElement): void
  • Replace an attached UI element. Will not do anything if called with an index that doesn't have a UI element.

    Parameters

    Returns void

shuffle

  • shuffle(): void

snap

  • snap(animationSpeed?: number): SnapPoint | undefined
  • Snap the object as if it was dropped at its current position. Does nothing if no snap point is in range below the object. Snapping in this way does not trigger the onSnapped callback. Returns the snapped point if the object was snapped. Optionally show an animation of the object rotating toward the new orientation. The animation is only visual, the physical rotation of the object is changed instantly. Does not have an effect if a player is currently holding the object.

    Parameters

    • Optional animationSpeed: number

      If larger than 0, show animation. A value of 1 gives a reasonable, quick animation. Value range clamped to [0.1, 5.0]. Default: 0

    Returns SnapPoint | undefined

snapToGround

  • snapToGround(): void

split

  • split(numStacks: number): Card[]
  • Split the card stack into a fixed number of smaller stacks with equal size. Some of the stacks will have one card more than others if the current stack size is not divisible by the number of stacks.

    Parameters

    • numStacks: number

      Number of stacks to split into

    Returns Card[]

    • The newly created stacks, starting with the stack at the bottom as the first item

switchLights

  • switchLights(on: boolean): void

takeCards

  • takeCards(numCards?: number, fromFront?: boolean, offset?: number, keep?: boolean): Card | undefined
  • Take a stack of cards from the stack. The new stack will be positioned directly above the original stack. If the number of cards to take is as large as the stack or larger, one card will remain in the original stack. Returns undefined if this object is only a single card.

    Parameters

    • Optional numCards: number

      Number of cards to take. Defaults to 1.

    • Optional fromFront: boolean

      If true, take the cards from the front of the stack instead of the back. Default: false

    • Optional offset: number

      Number of cards to leave at the back (or front when fromFront is true) before taking cards. Default: 0

    • Optional keep: boolean

      If true, keep the taken cards in the stack and take a copy. Default: false

    Returns Card | undefined

toJSONString

  • toJSONString(): string

toggleLock

  • toggleLock(): void
  • Immediately freeze the object and set its type to ground if it is currently not a ground object. Set its type to regular if it is currently a ground object. If you want to completely lock an object and not allow players to interact with it, use setObjectType with ObjectType.NonInteractive instead.

    Returns void

updateUI

  • Update an attached UI element. Will not do anything if called with a UI element that is not attached to the object. You need to call this method after modifying values in a UIElement. Does not work if you change the UIElement.widget property, you have to use setUI in this case.

    Parameters

    Returns void

worldPositionToLocal

  • worldPositionToLocal(position: Vector | [x: number, y: number, z: number]): Vector
  • Transform a world position to an object position

    Parameters

    • position: Vector | [x: number, y: number, z: number]

      The position in world space to transform to relative to the object

    Returns Vector

worldRotationToLocal

  • worldRotationToLocal(rotation: Rotator | [pitch: number, yaw: number, roll: number]): Rotator
  • Transform a world rotation to an object rotation

    Parameters

    • rotation: Rotator | [pitch: number, yaw: number, roll: number]

      The rotation in world space to transform to relative to the object

    Returns Rotator

Static getExecutionReason

  • getExecutionReason(): string
  • Used when executing an object script to determine why it was executed. Possible return values:
    "Create" - The object was newly created, for example from the object library or through copy and paste
    "ScriptReload" - The script was reloaded, for example because it was set on the object for the first time, or because the scripting environment was reset
    "StateLoad" - A game state that contained the object was loaded

    Returns string