31 July 2019

19 May 2015

28 February 2015

28 February 2015

The setviewereffect updates or creates a viewer effect (either LookAt, PointAt, beam or sphere).

CommandRequired ParametersRequired Corrade PermissionsExample
setviewereffectgroup, password, effectinteract
llInstantMessage(CORRADE,
    wasKeyValueEncode(
        [
            // Start a beam effect to the
            // primitive in which this
            // script is placed.
            "command", "setviewereffect",
            "group", wasURLEscape(GROUP),
            "password", wasURLEscape(PASSWORD),
            "effect", "beam",
            "item", wasURLEscape(llGetKey()),
            "range", 5,
            "callback", wasURLEscape(URL)
        ]
    )
);

With the possible parameter tree:

ParameterPossible ValueSub-ParameterPossible ValueDescription
effectlookitem, range or agent by UUID (agent) or by firstname and lastnameSets a LookAt on either an item in range or an avatar by agent UUID or by firstname and lastname.
offsetA vector describing an offset from Corrade.
typeA LookAt type.
pointitem, range or agent by UUID (agent) or by firstname and lastnameSets a PointAt on either an item in range or an avatar by agent UUID or by firstname and lastname.
offsetA vector describing an offset from Corrade.
typeA PointAt type.
beamitem, (optional range) or agent by UUID (agent) or by firstname and lastnameSets a beam on either an item in range or an avatar by agent UUID or by firstname and lastname.
colorAn LSL color vector.
alphaA value in the interval $[0, 1]$ describing the color alpha.
durationThe duration (in seconds) for the effect.
offsetA vector describing an offset from Corrade.
spherecolorAn LSL color vector.Creates a particle swirl effect.
alphaA value in the interval $[0, 1]$ describing the color alpha.
durationThe duration (in seconds) for the effect.
offsetA vector describing an offset from Corrade.

The command takes an optional parameter id, an UUID corresponding to an effect:

Optional ParameterPossible ValueDescription
idAn UUID.The UUID of the effect to set.
selectionattached, rezzed or all (default: all)Either attached, rezzed or all for selecting only primitives or objects attached to avatars, primitives or objects rezzed in-world or all primitives or objects respectively.

and in case id is not specified, then Corrade will generate a random UUID and, in the case of the look viewer effect, it will create a new beacon.

Notes

Look at Object or Avatar

The setviewereffect is a powerful command with which you can also make Corrade look at something or someone. Suppose that your name is Leslie Resident and that you would like your Corrade to look at you. In that case, you would issue the command as:

llInstantMessage(CORRADE, 
    wasKeyValueEncode(
        [
            "command", "setviewereffect",
            "group", llEscapeURL(GROUP),
            "password", llEscapeURL(PASSWORD),
            "effect", "look",
            "firstname", "Leslie",
            "lastname", "Resident",
            "offset", ZERO_VECTOR,
            "type", "Mouselook",
            "callback", llEscapeURL(URL)
        ]
    )
);

which will make Corrade look at Leslie Resident. You can also make Corrade look at an object the same way by using the item and optional range parameter.

If the command is successful, then Corrade will return the effect UUID in the data key to the callback URL. Suppose that Corrade returned the UUID af61fb35-8f84-4e28-a8d7-dd88c33ab99f, then this UUID can be used to make Corrade look at a different object by moving the beacon:

llInstantMessage(CORRADE, 
    wasKeyValueEncode(
        [
            "command", "setviewereffect",
            "group", llEscapeURL(GROUP),
            "password", llEscapeURL(PASSWORD),
            "effect", "look",
            "item", "46eda187-9382-4333-81df-4976ac5d8031",
            "range", 5,
            "offset", ZERO_VECTOR,
            "type", "Mouselook",
            "id", "af61fb35-8f84-4e28-a8d7-dd88c33ab99f",
            "callback", llEscapeURL(URL)
        ]
    )
);

Note the id that references the previous look beacon (af61fb35-8f84-4e28-a8d7-dd88c33ab99f). It is important to track the viewer effects because they can then be manipulated and set to different objects. The setviewereffect by default creates a new beacon in case an existing UUID is not supplied as the value of the id parameter. In other words, if you do not track your effects, Corrade will just create new beacons every time setviewereffect is called - this is especially true for the look viewer effect that cannot be deleted.