Skip to main content

Interactable

Associated namespace: sm.interactable

A userdata object representing an interactable shape in the game.

Values:
  • active [ bool ]

    • Get: The interactable's logic output signal.
    • Set: (Server-Only) Sets the interactable's logic output signal.
  • body [ Body ]

    • Get: The interactable shape's body.
  • id [ int ]

    • Get: The interactable's id.
  • power [ number ]

    • Get: The interactable's power output signal.
    • Set: (Server-Only) Sets the interactable's power output signal.
  • publicData [ table ]

    • Get: (Server-only) The interactable's server public data.
    • Set: (Server-Only) Sets the interactable's server public data.
  • shape [ Shape ]

    • Get: The interactable's shape.
  • type [ string ]

    • Get: The interactable's type.

Operations:
OperationDescription
Interactable == InteractableChecks if two instances of Interactable refer to the same Interactable.

Functions

addContainer

interactable:addContainer( index, size, stackSize )
Server-Only

Creates and stores a container in the given index inside the controller.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • index [ int ]: The index of the container (0 - 15).
  • size [ int ]: The number of slots in the container.
  • stackSize [ int ]: The stack size. Defaults to max stack size (65535).
Returns:

connect

interactable:connect( child )
Server-Only

Connects the interactable to another compatible interactable. Similar to using the Connect Tool.

Arguments:
Returns:
  • [ bool ]: Whether the connection was successful or not.

connectToJoint

interactable:connectToJoint( child )
Server-Only

Connects the interactable to a compatible joint.

Arguments:

disconnect

interactable:disconnect( child )
Server-Only

Disconnects the interactable from another interactable. Similar to using the Connect Tool.

Arguments:
Returns:
  • [ bool ]: Whether the disconnection was successful or not.

getAnimDuration

interactable:getAnimDuration( name )
Client-Only

Returns animation duration in seconds.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • name [ string ]: The name of the animation.
Returns:
  • [ number ]: The animation duration.

getBearings

interactable:getBearings()

Returns a table of bearings that the interactable is connected to.

Arguments:
Returns:
  • [ table ]: The table of connected bearings.

getBody

interactable:getBody()

Returns the body of the interactable's shape.

Arguments:
Returns:

getChildren

interactable:getChildren( connectionType )

Returns a table of child interactables that the interactable is connected to.
The children listen to the interactable's output.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • connectionType [ int ]: Connection type filter. Defaults to all types except bearing (for backwards compatibility).
Returns:
  • [ table ]: The table of connected child interactables.

getColorHighlight

interactable:getColorHighlight()

Returns the connection-point highlight color of the interactable.
This point color is shown when aiming at the shape with the Connect Tool.

Arguments:
Returns:

getColorNormal

interactable:getColorNormal()

Returns the connection-point color of the interactable.
This point color is shown when the Connect Tool is equipped.

Arguments:
Returns:

getConnectionInputType

interactable:getConnectionInputType()

Returns the interactable's input connection type.

Arguments:
Returns:
  • [ int ]: The connection type.

getConnectionOutputType

interactable:getConnectionOutputType()

Returns the interactable's output connection type.

Arguments:
Returns:
  • [ int ]: The connection type.

getContainer

interactable:getContainer( index )

Returns the container stored at the given index inside the controller.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • index [ int ]: The index (default 0).
Returns:

getGlowMultiplier

interactable:getGlowMultiplier()
Client-Only

Returns the interactable's glow multiplier.

Arguments:
Returns:
  • [ number ]: The glow multiplier (0.0 - 1.0).

getId

interactable:getId()

Returns the interactable's id.

Arguments:
Returns:
  • [ int ]: The id.

getJoints

interactable:getJoints()

Returns a table of all joints that an interactable is connected to.
Joints include bearings and pistons.

Arguments:
Returns:
  • [ table ]: The table of connected joints.

getLocalBonePosition

interactable:getLocalBonePosition( name )

Returns the local position of a bone.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • name [ string ]: The bone name.
Returns:

getMaxChildCount

interactable:getMaxChildCount()

Returns the maximum number of allowed child connections of the interactable - the number of outgoing connections.

Arguments:
Returns:
  • [ int ]: The max child connection count.

getMaxParentCount

interactable:getMaxParentCount()

Returns the maximum number of allowed parent connections of the interactable - the number of incoming connections.

Arguments:
Returns:
  • [ int ]: The max parent connection count.

getParents

interactable:getParents( connectionType )

Returns a table of parent interactables that are connected to the interactable.
The parents act as the interactable's input.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • connectionType [ int ]: Connection type filter. Defaults to all types.
Returns:
  • [ table ]: The table of connected parent interactables.

getPistons

interactable:getPistons()

Returns a table of pistons that the interactable is connected to.

Arguments:
Returns:
  • [ table ]: The table of connected pistons.

getPoseWeight

interactable:getPoseWeight( index )
Client-Only

Returns the pose weight of the pose in the given index.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • index [ int ]: The index.
Returns:
  • [ number ]: The pose weight.

getPower

interactable:getPower()

Returns the power output signal of the interactable.
This signal is usually a number between -1 to 1, where 1 is forward and -1 backward.
However, it can also be used for other numbers, such as the number logic of The Modpack.

Arguments:
Returns:
  • [ number ]: The power output signal.

getPublicData

interactable:getPublicData()
Server-Only

Returns the interactable's server public data.

Arguments:
Returns:
  • [ table ]: The public data.

getSeatCharacter

interactable:getSeatCharacter()

Returns the Character that is currently seated in the interactable.

Arguments:
Returns:

getSeatInteractables

interactable:getSeatInteractables()

Returns a table of interactables that are connected to the seat.

Arguments:
Returns:
  • [ table ]: The table of seat interactables.

getShape

interactable:getShape()

Returns the interactable's Shape.

Arguments:
Returns:
  • [ Shape ]: The interactable's host shape.

getSingleParent

interactable:getSingleParent()

Returns the interactable's parent interactable.
The parent act as the interactable's input.

warning

This method is not allowed for an interactable that allows more than one parent connection.

Arguments:
Returns:

getSteeringAngle

interactable:getSteeringAngle()

Returns the steering angle of the steering interactable.

The value ranges from -1 to +1, where -1 represents steering right
and +1 represents steering left.

Arguments:
Returns:
  • [ number ]: The steering angle.

getSteeringJointLeftAngleLimit

interactable:getSteeringJointLeftAngleLimit( joint )

Returns the left angle limit of a Joint connected to the steering Interactable.

Arguments:
Returns:
  • [ number ]: The left angle limit.

getSteeringJointLeftAngleSpeed

interactable:getSteeringJointLeftAngleSpeed( joint )

Returns the left angle speed of a Joint connected to the steering Interactable.

Arguments:
Returns:
  • [ number ]: The left angle speed.

getSteeringJointRightAngleLimit

interactable:getSteeringJointRightAngleLimit( joint )

Returns the right angle limit of a Joint connected to the steering Interactable.

Arguments:
Returns:
  • [ number ]: The right angle limit.

getSteeringJointRightAngleSpeed

interactable:getSteeringJointRightAngleSpeed( joint )

Returns the right angle speed of a Joint connected to the steering Interactable.

Arguments:
Returns:
  • [ number ]: The right angle speed.

getSteeringJointSettings

interactable:getSteeringJointSettings( joint )

Returns the settings of a Joint connected to the steering Interactable.

Arguments:
Returns:
  • [ number ]: The left angle speed.
  • [ number ]: The right angle speed.
  • [ number ]: The left angle limit.
  • [ number ]: The right angle limit.
  • [ bool ]: Whether the joint is unlocked or not.

getSteeringJointUnlocked

interactable:getSteeringJointUnlocked( joint )

Returns the lock state of a Joint connected to the steering Interactable.

Arguments:
Returns:
  • [ bool ]: Whether the joint is unlocked or not.

getSteeringPower

interactable:getSteeringPower()

Returns the steering power of the steering interactable.

The value ranges from -1 to +1, where +1 represents pressing "forward"
and -1 represents pressing "backwards".

Arguments:
Returns:
  • [ number ]: The steering power.

getType

interactable:getType()

Returns the interactable's type.

See sm.interactable.types for details.

Arguments:
Returns:
  • [ string ]: The type.

getUvFrameIndex

interactable:getUvFrameIndex()
Client-Only

Returns the index of the current UV animation frame.

Arguments:
Returns:
  • [ int ]: The UV frame.

getWorldBonePosition

interactable:getWorldBonePosition( name )

Returns the world position of a bone.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • name [ string ]: The bone name.
Returns:
  • [ Vec3 ]: The world position.

hasAnim

interactable:hasAnim( name )
Client-Only

Returns whether an animation exists.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • name [ string ]: The animation name.
Returns:
  • [ bool ]: Whether the animation exists or not.

hasOutputType

interactable:hasOutputType( type )

Returns whether the interactable has the specified output connection type.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • type [ int ]: The connection type.
Returns:
  • [ bool ]: Whether the interactable has the connection type or not.

hasSeat

interactable:hasSeat()

Returns whether the interactable has a seat component.

Arguments:
Returns:
  • [ bool ]: Whether the interactable has a seat component or not.

hasSteering

interactable:hasSteering()

Returns whether the interactable has a steering component.

Arguments:
Returns:
  • [ bool ]: Whether the interactable has a steering component or not.

isActive

interactable:isActive()

Returns the interactable's logic output signal.
This signal is a boolean, on or off.

Arguments:
Returns:
  • [ bool ]: The logic output signal.

pressSeatInteractable

interactable:pressSeatInteractable( index )

Triggers a press interaction on an interactable connected to the seat.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • index [ int ]: The index of the interactable.
Returns:
  • [ bool ]: Whether the action was successful or not.

releaseSeatInteractable

interactable:releaseSeatInteractable( index )

Triggers a release interaction on an interactable connected to the seat.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • index [ int ]: The index of the interactable.
Returns:
  • [ bool ]: Whether the action was successful or not.

removeContainer

interactable:removeContainer( index )
Server-Only

Removes the container stored in the given index inside the controller.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • index [ int ]: The index of the container.

setActive

interactable:setActive( signal )
Server-Only

Sets the logic output signal of an interactable.
This signal is a boolean, on or off.

warning

Every time an interactable's logic output signal ("active state") changes,
this change is transmitted over the network to every connected client.

This means, if a large amount of interactables update their states too often, this can have
a significant impact on multiplayer performance, to the point of becoming almost unplayable.

To avoid causing such problems, change the interactable's "active state" only
if neccessary (and make sure to not set it every tick, if possible).

Arguments:
  • interactable [ Interactable ]: The interactable.
  • signal [ bool ]: The logic output signal.

setAnimEnabled

interactable:setAnimEnabled( name, enabled )
Client-Only

Sets whether the animation with the given name should be applied to the mesh.
True enables the animation and false disables it.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • name [ string ]: The animation name.
  • enabled [ bool ]: Whether the animation is enabled or not.

setAnimProgress

interactable:setAnimProgress( name, progress )
Client-Only

Sets the progress on the animation with the given name.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • name [ string ]: The animation name.
  • progress [ number ]: The progress (between 0 and 1).

setGlowMultiplier

interactable:setGlowMultiplier( value )
Client-Only

Sets a value to multiply the glow from asg texture with.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • value [ number ]: The glow multiplier.

setGyroDirection

interactable:setGyroDirection( direction )
Client-Only

Sets the direction of the gyro.

Arguments:

setParams

interactable:setParams( data )

Sets the interactable's script param data.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • data [ any ]: The param data.

setPoseWeight

interactable:setPoseWeight( index, value )
Client-Only

Set the pose weight of the pose in the given index.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • index [ int ]: The index.
  • value [ number ]: The pose weight.

setPower

interactable:setPower( signal )
Server-Only

Sets the power output signal of the interactable.
This signal is usually a number between -1 to 1, where 1 is forward and -1 backward.
However, it can also be used for other numbers, such as the number logic of The Modpack.

warning

Every time an interactable's power output signal ("power") changes,
this change is transmitted over the network to every connected client.

This means, if a large amount of interactables update their "power" too often, this can have
a significant impact on multiplayer performance, to the point of becoming almost unplayable.

To avoid causing such problems, change the interactable's "power" only
if neccessary (and make sure to not set it every tick, if possible).

Arguments:
  • interactable [ Interactable ]: The interactable.
  • signal [ number ]: The power output signal.

setPublicData

interactable:setPublicData( data )
Server-Only

Set the interactable's server public data.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • data [ table ]: The data to set.

setSeatCharacter

interactable:setSeatCharacter( character )

Requests to seat a Character in the Interactable.

Arguments:

setSteeringFlag

interactable:setSteeringFlag( flag )

Sets the steering flag for the steering interactable.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • flag [ int ]: The steering flag.

setSteeringJointLeftAngleLimit

interactable:setSteeringJointLeftAngleLimit( joint, value )
Client-Only

Sets the left angle limit settings of a Joint connected to the steering Interactable.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • joint [ Joint ]: The joint.
  • value [ number ]: The left angle limit.

setSteeringJointLeftAngleSpeed

interactable:setSteeringJointLeftAngleSpeed( joint, value )
Client-Only

Sets the left angle speed settings of a Joint connected to the steering Interactable.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • joint [ Joint ]: The joint.
  • value [ number ]: The left angle speed.

setSteeringJointRightAngleLimit

interactable:setSteeringJointRightAngleLimit( joint, value )
Client-Only

Sets the right angle limit settings of a Joint connected to the steering Interactable.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • joint [ Joint ]: The joint.
  • value [ number ]: The right angle limit.

setSteeringJointRightAngleSpeed

interactable:setSteeringJointRightAngleSpeed( joint, value )
Client-Only

Sets the right angle speed settings of a Joint connected to the steering Interactable.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • joint [ Joint ]: The joint.
  • value [ number ]: The right angle speed.

setSteeringJointSettings

interactable:setSteeringJointSettings( joint, leftSpeed, rightSpeed, leftLimit, rightLimit, unlocked )
Client-Only

Sets the right angle speed settings of a Joint connected to the steering Interactable.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • joint [ Joint ]: The joint.
  • leftSpeed [ number ]: The left angle speed.
  • rightSpeed [ number ]: The right angle speed.
  • leftLimit [ number ]: The left angle limit.
  • rightLimit [ number ]: The right angle limit.
  • unlocked [ bool ]: Whether the joint is unlocked or not.

setSteeringJointUnlocked

interactable:setSteeringJointUnlocked( joint, value )
Client-Only

Sets the lock state of a Joint connected to the steering Interactable.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • joint [ Joint ]: The joint.
  • value [ bool ]: Whether the joint is unlocked or not.

setSubMeshVisible

interactable:setSubMeshVisible( name, visible )
Client-Only

Sets the visibility of a submesh.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • name [ string ]: The submesh name.
  • visible [ bool ]: Whether the submesh is visible or not.

setUvFrameIndex

interactable:setUvFrameIndex( index )
Client-Only

Sets the UV animation frame with the given index.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • index [ int ]: The index.

unsetSteeringFlag

interactable:unsetSteeringFlag( flag )

Unsets the steering flag for a steering interactable.

Arguments:
  • interactable [ Interactable ]: The interactable.
  • flag [ int ]: The steering flag.