LSL Prim Manipulation

By Xah Lee. Date: .

A prim's shape, size, orientation, position, texture, color, can all be changed by a script.

To change a prim, use llSetPrimitiveParams(). The llSetPrimitiveParams() takes a list of arguments, of the form [p1,p1values,p1values…, p2,p2values,p2values, …], were the p are prim property names followed by its values to be set.

Primitive properties include: size, shape (twist, taper…), color and texture, orientation and position, physical attributes (full bright, phantom…) …

These can also be done with more specific functions. e.g.: llSetScale(), llSetColor(), llSetPos(), llSetRot()…

// touch to turn light on and off

integer onoff=FALSE;

default
{
    touch_start(integer total_number)
    {
        if (onoff==FALSE)
        { llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, <1, 1, 1>, 1.0, 10.0, 0.75] ); onoff=TRUE; }
        else
        { llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE, <1, 1, 1>, 1.0, 10.0, 0.75] ); onoff=FALSE;}
    }
}

// that's: color, intensity, radius, falloff rate
// Simulate a beacon.
// using a timer to periodically toggle the prim's point light

integer onoff=FALSE;
default
{
  state_entry() { llSetTimerEvent(2); }

    timer()
    {
      if (onoff==FALSE)
        { llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, <1,0,0>, 1, 10, 1.] ); onoff=TRUE; }
      else
        { llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE, <1, 1, 1>, 1.0, 10.0, 0.75] ); onoff=FALSE;}
    }
}

// that's: color, intensity, radius, falloff rate