Skip to main content

Effect

Associated namespace: sm.effect

A userdata object representing an effect.

Values:

  • id [ int ]

    • Get: The id of the effect.

Operations:

OperationDescription
Effect == EffectChecks if two instances of Effect refer to the same Effect.

Functions

bindEventCallback

effect:bindEventCallback( methodName, params, reference )

Client-Only

Bind a Lua callback to be triggered by the effect.

Parameters:

  • effect (Effect): The effect.
  • methodName (string): The name of the callback function.
  • params (any): Parameter object passed to the callback (Optional).
  • reference (table): Table to receive the callback (Optional).

clearEventCallbacks

effect:clearEventCallbacks()

Client-Only

Clears all Lua effect callbacks.

Parameters:


destroy

effect:destroy()

Stops and destroys the effect.

Parameters:


getCameraFov

effect:getCameraFov()

Client-Only

Get the desired camera FOV.

Will return nil if the effect is not playing.

Parameters:

Returns:

  • (number): The FOV.

getCameraPosition

effect:getCameraPosition()

Client-Only

Get the desired camera position.

Will return nil if the effect is not playing.

Parameters:

Returns:

  • (Vec3): The position.

getCameraRotation

effect:getCameraRotation()

Client-Only

Get the desired camera rotation.

Will return nil if the effect is not playing.

Parameters:

Returns:

  • (Quat): The rotation.

getId

effect:getId()

Returns the id of the effect.

Parameters:

Returns:

  • (int): The id.

hasActiveCamera

effect:hasActiveCamera()

Client-Only

Returns whether the effect has an active camera effect.

Parameters:

Returns:

  • (boolean): Whether the effect has an active camera effect or not.

isDone

effect:isDone()

Client-Only

Returns whether the effect is done, meaning that all effect instances have finished.

Parameters:

Returns:

  • (boolean): Whether the effect is done or not.

isPlaying

effect:isPlaying()

Client-Only

Returns whether the effect is currently playing.

Parameters:

Returns:

  • (boolean): Whether the effect is playing or not.

setAutoPlay

effect:setAutoPlay( enabled )

Client-Only

Sets the effect to start playing and repeating automatically.

Parameters:

  • effect (Effect): The effect.
  • enabled (boolean): Whether the effect repeats automatically or not.

setOffsetPosition

effect:setOffsetPosition( position )

Client-Only

Offsets the position of the effect relative to the host interactable.

note

This does not work if the effect was created without a host interactable.

Parameters:

  • effect (Effect): The effect.
  • position (Vec3): The offset position.

setOffsetRotation

effect:setOffsetRotation( rotation )

Client-Only

Offsets the rotation of the effect relative to the host interactable.

note

This does not work if the effect was created without a host interactable.

Parameters:

  • effect (Effect): The effect.
  • rotation (Quat): The offset rotation.

setParameter

effect:setParameter( name, value )

Client-Only

Sets a named parameter value on the effect.

Parameters:

  • effect (Effect): The effect.
  • name (string): The parameter name.
  • value (any): The parameter value.

The list below contains some of the possible parameter names.
Note that some of these may only work for specific effects.

Velocity_max_50
minColor
maxColor
minColor2
maxColor2
valid
progress
char
Material
velocity_tree
craftbot
size
impact
load
rpm
gas
pitch
health
fire_intensity
visualization
amb_day_night
music

setPosition

effect:setPosition( position )

Client-Only

Sets the position of the effect.

note

This does not work if the effect was created with a host interactable.

Parameters:

  • effect (Effect): The effect.
  • position (Vec3): The position.

setRotation

effect:setRotation( rotation )

Client-Only

Sets the rotation of the effect.

note

This does not work if the effect was created with a host interactable.

Parameters:

  • effect (Effect): The effect.
  • rotation (Quat): The rotation.

setScale

effect:setScale( scale )

Client-Only

Sets the scale of the effect.

note

Only applies to effect renderables.

Parameters:

  • effect (Effect): The effect.
  • scale (Vec3): The scale.

setTimeOfDay

effect:setTimeOfDay( enabled, startTime, endTime, inversed )

Client-Only

Sets the effect to be active during specific period of the day / night cycle.

Parameters:

  • effect (Effect): The effect.
  • enabled (boolean): Whether this feature is enabled or not.
  • startTime (number): The normalized start time.
  • endTime (number): The normalized end time.
  • inversed (boolean): If true, period between start/end becomes inactive time.

setVelocity

effect:setVelocity( velocity )

Client-Only

Sets the velocity of the effect.
The effect will move along at the set velocity until it receives a new position.

note

This does not work if the effect was created with a host interactable.

Parameters:

  • effect (Effect): The effect.
  • velocity (Vec3): The velocity.

setWorld

effect:setWorld( world )

Client-Only

Sets the effect's world.

Parameters:

  • effect (Effect): The effect.
  • world (World): The world. Defaults to world from script context.

start

effect:start()

Client-Only

Starts playing the effect.

Parameters:


stop

effect:stop()

Client-Only

Stops playing the effect.

Parameters:


stopBreakSustain

effect:stopBreakSustain()

Client-Only

Stops playing the effect, letting sound finish before destroying the effect.

Parameters:


stopImmediate

effect:stopImmediate()

Client-Only

Immediately stops playing the effect. Any playing sound effects will stop immediately.

Parameters: