Effect
Associated namespace: sm.effect
A userdata object representing an effect.
Values:
Functions:
- bindEventCallback
- bindEventClientCallback
- bindEventServerCallback
- clearClientEventCallback
- clearEventCallbacks
- clearServerEventCallback
- destroy
- detach
- getCameraData
- getId
- getWorldPosition
- hasActiveCamera
- hasHost
- isBreakSustaining
- isDone
- isPlaying
- setAutoPlay
- setDetachOnHostDestroy
- setHost
- setHost
- setHost
- setHost
- setHostAxisIgnore
- setOffsetPosition
- setOffsetRotation
- setParameter
- setPosition
- setRotation
- setScale
- setStartStopDistance
- setTimeOfDay
- setVelocity
- setWorld
- setWorldAny
- start
- stop
- stopBreakSustain
- stopImmediate
Operations:
| Operation | Return type | Description |
|---|---|---|
| Effect == Effect | boolean | Checks 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:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
| string | methodName | The name of the callback method being bound. Example: MyClass.methodName( self, event, params ) |
| any | params? | Parameter object passed to the callback. (Optional) |
| table | reference? | 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:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
| any | params? | Parameter object passed to the callback. (Optional) |
| table | reference? | 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:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
| any | params? | Parameter object passed to the callback. (Optional) |
| table | reference? | Table to receive the callback. (Optional) |
clearClientEventCallback(effect)
Client only
Clear the effect lua client callback script reference.
Parameters:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
clearEventCallbacks(effect)
Deprecated:
use Effect.clearClientEventCallback together with Effect.bindEventClientCallback instead.
Client only
Clear all lua effect callbacks.
Parameters:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
clearServerEventCallback(effect)
Client only
Clear the effect lua server callback script reference.
Parameters:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
destroy(effect)
Stops and destroys the effect.
Parameters:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
detach(effect)
Client only
Detaches the effect from its host object.
Parameters:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
getCameraData(effect)
Client only
Get a table of camera effect data.
Returns nil if the effect is not a camera effect.
Parameters:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
Returns:
| Type | Description |
|---|---|
| table | The settings. { hasBlendIn = boolean, hasBlendOut = boolean, active = boolean, cameraPosition = Vec3, cameraRotation = Quat, cameraFov = number } |
getId(effect)
Returns the id of an effect.
Parameters:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
Returns:
| Type | Description |
|---|---|
| integer | The effect's id. |
getWorldPosition(effect)
Client only
Gets the current world position
Parameters:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
Returns:
| Type | Description |
|---|---|
| Vec3 The world position. |
hasActiveCamera(effect)
Client only
Check if the effect has an active camera effect.
Parameters:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
Returns:
| Type | Description |
|---|---|
| boolean | Is active. |
hasHost(effect)
Client only
Returns whether the effect has a host.
Parameters:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
Returns:
| Type | Description |
|---|---|
| boolean | Whether the effect is hosted. |
isBreakSustaining(effect)
Client only
Returns whether the effect is break sustained.
Parameters:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
Returns:
| Type | Description |
|---|---|
| boolean | Whether effect is break sustained. |
isDone(effect)
Client only
Returns whether the effect is done, meaning that all effect instances have finished.
Parameters:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
Returns:
| Type | Description |
|---|---|
| boolean | Whether effect is done. |
isPlaying(effect)
Client only
Returns whether the effect is currently playing.
Parameters:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
Returns:
| Type | Description |
|---|---|
| boolean | Whether effect is playing. |
setAutoPlay(effect, autoplay, autoPlayOnce?, resetPlayOnce?)
Client only
Sets an effect to start playing and repeating automatically.
Parameters:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
| boolean | autoplay | Autoplay enabled. |
| boolean | autoPlayOnce? | If set the effect will not loop when autoplaying. (Defaults to false) (Optional) |
| boolean | resetPlayOnce? | 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:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
| boolean | detach | If 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:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
| Interactable | Interactable | The Interactable the effect is attached to. |
| string | boneName? | 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:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
| Shape | shape | The shape the effect is attached to. |
| string | boneName? | 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:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
| Character | Character | The Character the effect is attached to. |
| string | boneName? | 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:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
| Harvestable | pHarvestable | The pHarvestable the effect is attached to. |
| string | boneName? | 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:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
| integer | axis | The 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:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
| Vec3 | offsetPosition | The 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:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
| Quat | offsetRotation | The relative offset rotation. |
setParameter(effect, name, value)
Client only
Sets a named parameter value on the effect.
Parameters:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
| string | name | The name. |
| any | value | The 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:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
| Vec3 | position | The 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:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
| Quat | rotation | The rotation. |
setScale(effect, scale)
Client only
Sets the scale of an effect.
Note:
Only applies to effect renderables.
Parameters:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
| Vec3 | scale | The scale. |
setStartStopDistance(effect, startDistance, stopDistance)
Client only
Sets an effect to stop and restart depending on distance to the player.
Parameters:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
| number | startDistance | The distance when effect will start |
| number | stopDistance | The 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:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
| boolean | enabled | Time of day enabled. |
| number | start | Start normalized time of day. |
| number | end | End normalized time of day. |
| boolean | inversed | If 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:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
| Vec3 | velocity | The velocity. |
setWorld(effect, world)
Client only
Sets the world for an effect.
Parameters:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
| World | world | The 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:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
start(effect, startTime?)
Client only
Starts playing an effect.
Parameters:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
| number | startTime? | 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:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
stopBreakSustain(effect)
Client only
Stops playing an effect, letting sound finish before destroying the effect.
Parameters:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |
stopImmediate(effect)
Client only
Immediately stop playing an effect, sound effects ended immediately.
Parameters:
| Type | Name | Description |
|---|---|---|
| Effect | effect | The effect. |