Effect

Associated namespace: sm.effect

A userdata object representing an effect.

Values:

Functions:

Operations:

OperationReturn typeDescription
Effect == EffectbooleanChecks if two instances of Effect refer to the same Effect.

id integer

Get:

Returns the id of an effect.


bindEventCallback(effect, methodName, params?, reference?)

Deprecated:

use Effect.bindEventClientCallback instead.

Client only

Bind a lua callback to be triggered by the effect.

Parameters:

TypeNameDescription
EffecteffectThe effect.
stringmethodNameThe name of the callback method being bound. Example: MyClass.methodName( self, event, params )
anyparams?Parameter object passed to the callback. (Optional)
tablereference?Table to receive the callback. (Optional)

bindEventClientCallback(effect, params?, reference?)

Client only

Bind a lua client callback script reference to be used by the effect.

Parameters:

TypeNameDescription
EffecteffectThe effect.
anyparams?Parameter object passed to the callback. (Optional)
tablereference?Table to receive the callback. (Optional)

bindEventServerCallback(effect, params?, reference?)

Client only

Bind a lua server callback script reference to be used by the effect. Host only.

Parameters:

TypeNameDescription
EffecteffectThe effect.
anyparams?Parameter object passed to the callback. (Optional)
tablereference?Table to receive the callback. (Optional)

clearClientEventCallback(effect)

Client only

Clear the effect lua client callback script reference.

Parameters:

TypeNameDescription
EffecteffectThe effect.

clearEventCallbacks(effect)

Deprecated:

use Effect.clearClientEventCallback together with Effect.bindEventClientCallback instead.

Client only

Clear all lua effect callbacks.

Parameters:

TypeNameDescription
EffecteffectThe effect.

clearServerEventCallback(effect)

Client only

Clear the effect lua server callback script reference.

Parameters:

TypeNameDescription
EffecteffectThe effect.

destroy(effect)

Stops and destroys the effect.

Parameters:

TypeNameDescription
EffecteffectThe effect.

detach(effect)

Client only

Detaches the effect from its host object.

Parameters:

TypeNameDescription
EffecteffectThe effect.

getCameraData(effect)

Client only

Get a table of camera effect data.

Returns nil if the effect is not a camera effect.

Parameters:

TypeNameDescription
EffecteffectThe effect.

Returns:

TypeDescription
tableThe settings. { hasBlendIn = boolean, hasBlendOut = boolean, active = boolean, cameraPosition = Vec3, cameraRotation = Quat, cameraFov = number }

getId(effect)

Returns the id of an effect.

Parameters:

TypeNameDescription
EffecteffectThe effect.

Returns:

TypeDescription
integerThe effect's id.

getWorldPosition(effect)

Client only

Gets the current world position

Parameters:

TypeNameDescription
EffecteffectThe effect.

Returns:

TypeDescription
Vec3 The world position.

hasActiveCamera(effect)

Client only

Check if the effect has an active camera effect.

Parameters:

TypeNameDescription
EffecteffectThe effect.

Returns:

TypeDescription
booleanIs active.

hasHost(effect)

Client only

Returns whether the effect has a host.

Parameters:

TypeNameDescription
EffecteffectThe effect.

Returns:

TypeDescription
booleanWhether the effect is hosted.

isBreakSustaining(effect)

Client only

Returns whether the effect is break sustained.

Parameters:

TypeNameDescription
EffecteffectThe effect.

Returns:

TypeDescription
booleanWhether effect is break sustained.

isDone(effect)

Client only

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

Parameters:

TypeNameDescription
EffecteffectThe effect.

Returns:

TypeDescription
booleanWhether effect is done.

isPlaying(effect)

Client only

Returns whether the effect is currently playing.

Parameters:

TypeNameDescription
EffecteffectThe effect.

Returns:

TypeDescription
booleanWhether effect is playing.

setAutoPlay(effect, autoplay, autoPlayOnce?, resetPlayOnce?)

Client only

Sets an effect to start playing and repeating automatically.

Parameters:

TypeNameDescription
EffecteffectThe effect.
booleanautoplayAutoplay enabled.
booleanautoPlayOnce?If set the effect will not loop when autoplaying. (Defaults to false) (Optional)
booleanresetPlayOnce?Will reset the autoPlayOnce condition, allowing the effect to play again if it already has since earlier. (Defaults to false) (Optional)

setDetachOnHostDestroy(effect, detach)

Client only

Detaches the effect from its host object when the host disappears.

Parameters:

TypeNameDescription
EffecteffectThe effect.
booleandetachIf the effect should automatically detach from the host or not.

setHost(effect, Interactable, boneName?)

Client only

Sets a Interactable as host for an effect.

Parameters:

TypeNameDescription
EffecteffectThe effect.
InteractableInteractableThe Interactable the effect is attached to.
stringboneName?The bone name to attach effect to. (Defaults to not attached to a bone) (Optional)

setHost(effect, shape, boneName?)

Client only

Sets a Shape as host for an effect.

Parameters:

TypeNameDescription
EffecteffectThe effect.
ShapeshapeThe shape the effect is attached to.
stringboneName?The bone name to attach effect to. (Defaults to not attached to a bone) (Optional)

setHost(effect, Character, boneName?)

Client only

Sets a Character as host for an effect.

Parameters:

TypeNameDescription
EffecteffectThe effect.
CharacterCharacterThe Character the effect is attached to.
stringboneName?The bone name to attach effect to. (Defaults to not attached to a bone) (Optional)

setHost(effect, pHarvestable, boneName?)

Client only

Sets a Harvestable as host for an effect.

Parameters:

TypeNameDescription
EffecteffectThe effect.
HarvestablepHarvestableThe pHarvestable the effect is attached to.
stringboneName?The bone name to attach effect to. (Defaults to not attached to a bone) (Optional)

setHostAxisIgnore(effect, axis)

Client only

Sets a rotation axis which hosted effects will ignore.

Parameters:

TypeNameDescription
EffecteffectThe effect.
integeraxisThe rotation axis.

setOffsetPosition(effect, offsetPosition)

Client only

Offsets the position of the effect relatively to the host.

Note:

Does not work if the effect was created without a host.

Parameters:

TypeNameDescription
EffecteffectThe effect.
Vec3offsetPositionThe relative offset position.

setOffsetRotation(effect, offsetRotation)

Client only

Offsets the orientation of the effect relatively to the host.

Note:

Does not work if the effect was created without a host.

Parameters:

TypeNameDescription
EffecteffectThe effect.
QuatoffsetRotationThe relative offset rotation.

setParameter(effect, name, value)

Client only

Sets a named parameter value on the effect.

Parameters:

TypeNameDescription
EffecteffectThe effect.
stringnameThe name.
anyvalueThe effect parameter value.

setPosition(effect, position)

Client only

Sets the position of an effect.

Note:

Does not work if the effect has a host.

Parameters:

TypeNameDescription
EffecteffectThe effect.
Vec3positionThe position.

setRotation(effect, rotation)

Client only

Sets the orientation of an effect using a quaternion.

Note:

Does not work if the effect has a host.

Parameters:

TypeNameDescription
EffecteffectThe effect.
QuatrotationThe rotation.

setScale(effect, scale)

Client only

Sets the scale of an effect.

Note:

Only applies to effect renderables.

Parameters:

TypeNameDescription
EffecteffectThe effect.
Vec3scaleThe scale.

setStartStopDistance(effect, startDistance, stopDistance)

Client only

Sets an effect to stop and restart depending on distance to the player.

Parameters:

TypeNameDescription
EffecteffectThe effect.
numberstartDistanceThe distance when effect will start
numberstopDistanceThe distance when effect will stop

setTimeOfDay(effect, enabled, start, end, inversed)

Client only

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

Parameters:

TypeNameDescription
EffecteffectThe effect.
booleanenabledTime of day enabled.
numberstartStart normalized time of day.
numberendEnd normalized time of day.
booleaninversedIf true, period between start-end becomes inactive time.

setVelocity(effect, velocity)

Client only

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

Note:

Does not work if the effect has a host.

Parameters:

TypeNameDescription
EffecteffectThe effect.
Vec3velocityThe velocity.

setWorld(effect, world)

Client only

Sets the world for an effect.

Parameters:

TypeNameDescription
EffecteffectThe effect.
WorldworldThe world. Defaults to world from script context. (optional)

setWorldAny(effect)

Client only

Sets the effect's world to UWorldId_Any, used to play global sounds through the dialog manager.

Parameters:

TypeNameDescription
EffecteffectThe effect.

start(effect, startTime?)

Client only

Starts playing an effect.

Parameters:

TypeNameDescription
EffecteffectThe effect.
numberstartTime?The start time of the effect. Only applies to audio and cinematic effects. (Defaults to 0)

stop(effect)

Client only

Stops playing an effect

Parameters:

TypeNameDescription
EffecteffectThe effect.

stopBreakSustain(effect)

Client only

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

Parameters:

TypeNameDescription
EffecteffectThe effect.

stopImmediate(effect)

Client only

Immediately stop playing an effect, sound effects ended immediately.

Parameters:

TypeNameDescription
EffecteffectThe effect.