sm.effect

Associated object type: Effect

The effect api handles the creation and playing of audio and visual effects.

Effects can consist of multiple components each being of separate types and with unique offsets, rotations and delays.

For more information on how to setup effects please take a look in the Effects/Database/EffectSets folder in the game data.

Functions:

  • createEffect
  • createEffect
  • createEffect
  • createEffect
  • createEffect2D
  • estimateSize
  • playEffect
  • playHostedEffect
  • playHostedEffect
  • playHostedEffect

  • sm.effect.createEffect(name)

    Client only

    Creates an effect.

    Parameters:

    TypeNameDescription
    stringnameThe name.

    Returns:

    TypeDescription
    EffectThe created effect.

    sm.effect.createEffect(name, interactable, name=nil)

    Client only

    Creates an effect.

    If you provide a host interactable to the effect then it will fetch position, velocity and orientation data from the interactable instead of relying on this information being fed to it.

    This results in far more accurate positioning of effects that are supposed to stay attached to an object.

    Parameters:

    TypeNameDescription
    stringnameThe name.
    InteractableinteractableThe interactable the effect is attached to.
    stringname=nilThe bone name. (Defaults to not attached to a bone) (Optional)

    Returns:

    TypeDescription
    EffectThe created effect.

    sm.effect.createEffect(name, harvestable)

    Client only

    Creates an effect.

    If you provide a host harvestable to the effect then it will fetch position, velocity and orientation data from the harvestable instead of relying on this information being fed to it.

    This results in far more accurate positioning of effects that are supposed to stay attached to an object.

    Parameters:

    TypeNameDescription
    stringnameThe name.
    HarvestableharvestableThe harvestable the effect is attached to.

    Returns:

    TypeDescription
    EffectThe created effect.

    sm.effect.createEffect(name, character, name=nil)

    Client only

    Creates an effect.

    If you provide a host character to the effect then it will fetch position, velocity and orientation data from the character instead of relying on this information being fed to it.

    This results in far more accurate positioning of effects that are supposed to stay attached to an object.

    Parameters:

    TypeNameDescription
    stringnameThe name.
    CharactercharacterThe character the effect is attached to.
    stringname=nilThe bone name. (Defaults to not attached to a bone) (Optional)

    Returns:

    TypeDescription
    EffectThe created effect.

    sm.effect.createEffect2D(name)

    Client only

    Creates an 2d effect.

    Parameters:

    TypeNameDescription
    stringnameThe name of the effect.

    Returns:

    TypeDescription
    EffectThe created effect.

    sm.effect.estimateSize(name, parameters)

    Client only

    Estimates the radius of influence for an effect and instance parameters

    Parameters:

    TypeNameDescription
    stringnameThe name of the effect.
    tableparametersTable of params

    Returns:

    TypeDescription
    numberThe Range

    sm.effect.playEffect(name, position, velocity=nil, rotation=nil, scale=nil, parameters=nil)

    Plays an effect. If this function is called on the server it will play the effect on all clients.

    Note:

    If you start a looping effect using this function you will not be able to stop it.
    Please use createEffect for looping effects.

    Parameters:

    TypeNameDescription
    stringnameThe name.
    Vec3positionThe position.
    Vec3velocity=nilThe velocity. (Defaults to no velocity)
    Quatrotation=nilThe rotation. (Defaults to no rotation)
    Vec3scale=nilThe scale. (Defaults to no scale, only applied to renderables)
    tableparameters=nilThe table containing the parameters for the effect.

    sm.effect.playHostedEffect(name, interactable, boneName=nil, parameters=nil)

    Client only

    Plays an effect. It will fetch position, velocity and orientation data from the host interactable.

    Note:

    If you start a looping effect using this function you will not be able to stop it.
    Please use createEffect for looping effects

    Parameters:

    TypeNameDescription
    stringnameThe effect name.
    InteractableinteractableThe interactable the effect is attached to.
    stringboneName=nilThe bone name. (Optional)
    tableparameters=nilThe table containing the parameters for the effect. (Optional)

    sm.effect.playHostedEffect(name, harvestable, parameters=nil)

    Client only

    Plays an effect. It will fetch position, velocity and orientation data from the host harvestable.

    Note:

    If you start a looping effect using this function you will not be able to stop it.
    Please use createEffect for looping effects

    Parameters:

    TypeNameDescription
    stringnameThe effect name.
    HarvestableharvestableThe harvestable the effect is attached to.
    tableparameters=nilThe table containing the parameters for the effect. (Optional)

    sm.effect.playHostedEffect(name, character, boneName=nil, parameters=nil)

    Client only

    Plays an effect. It will fetch position, velocity and orientation data from the host character.

    Note:

    If you start a looping effect using this function you will not be able to stop it.
    Please use createEffect for looping effects

    Parameters:

    TypeNameDescription
    stringnameThe effect name.
    CharactercharacterThe charcater the effect is attached to.
    stringboneName=nilThe bone name. (Optional)
    tableparameters=nilThe table containing the parameters for the effect. (Optional)