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.

The callback receives:

  • self [ table ]: The class instance.
  • eventName [ string ]: The name of the event.
  • params [ any ]: Parameter object passed to the callback.
Arguments:
  • 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.

Arguments:

destroy

effect:destroy()

Stops and destroys the effect.

Arguments:

getCameraFov

effect:getCameraFov()
Client-Only

Get the desired camera FOV.

Will return nil if the effect is not playing.

Arguments:
Returns:
  • [ number ]: The FOV.

getCameraPosition

effect:getCameraPosition()
Client-Only

Get the desired camera position.

Will return nil if the effect is not playing.

Arguments:
Returns:

getCameraRotation

effect:getCameraRotation()
Client-Only

Get the desired camera rotation.

Will return nil if the effect is not playing.

Arguments:
Returns:

getId

effect:getId()

Returns the id of the effect.

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

hasActiveCamera

effect:hasActiveCamera()
Client-Only

Returns whether the effect has an active camera effect.

Arguments:
Returns:
  • [ bool ]: 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.

Arguments:
Returns:
  • [ bool ]: Whether the effect is done or not.

isPlaying

effect:isPlaying()
Client-Only

Returns whether the effect is currently playing.

Arguments:
Returns:
  • [ bool ]: Whether the effect is playing or not.

setAutoPlay

effect:setAutoPlay( enabled )
Client-Only

Sets the effect to start playing and repeating automatically.

Arguments:
  • effect [ Effect ]: The effect.
  • enabled [ bool ]: 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.

Arguments:
  • 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.

Arguments:
  • effect [ Effect ]: The effect.
  • rotation [ Quat ]: The offset rotation.

setParameter

effect:setParameter( name, value )
Client-Only

Sets a named parameter value on the effect.

Arguments:
  • 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.

Arguments:

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.

Arguments:

setScale

effect:setScale( scale )
Client-Only

Sets the scale of the effect.

note

Only applies to effect renderables.

Arguments:

setTimeOfDay

effect:setTimeOfDay( enabled, startTime, endTime, inversed )
Client-Only

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

Arguments:
  • effect [ Effect ]: The effect.
  • enabled [ bool ]: Whether this feature is enabled or not.
  • startTime [ number ]: The normalized start time.
  • endTime [ number ]: The normalized end time.
  • inversed [ bool ]: 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.

Arguments:

setWorld

effect:setWorld( world )
Client-Only

Sets the effect's world.

Arguments:
  • effect [ Effect ]: The effect.
  • world [ World ]: The world. Defaults to world from script context.

start

effect:start()
Client-Only

Starts playing the effect.

Arguments:

stop

effect:stop()
Client-Only

Stops playing the effect.

Arguments:

stopBreakSustain

effect:stopBreakSustain()
Client-Only

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

Arguments:

stopImmediate

effect:stopImmediate()
Client-Only

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

Arguments: