Skip to content
lsl.devlsl.devLSL Dev

PRIM MATERIAL

Looking for the current API? Open the PRIM_MATERIAL reference →

Wiki description

Sets the prim material. Material does not affect mass, but does affect friction, bounce (elasticity), and collision sound. On a wood incline of 33 degrees, the example script below gave the following results:
Table detailing maximum velocity and distance traveled down the incline.
TypeVelocity (m/s)Distance (m)
Stone0.4531810.361655
Metal5.47544410.211180
Glass6.48315011.678304
Wood2.1545499.433724
Flesh0.3515430.188043
Plastic4.5024289.590952
Rubber0.3749640.187106

Examples

// © 2008 by Karzita Zabaleta
// Author of Scripting Your World, Wiley, October 2008.

list gMaterialTypes = [
  "STONE",
  "METAL",
  "GLASS",
  "WOOD",
  "FLESH",
  "PLASTIC",
  "RUBBER"
];

vector   gHomePosition;
rotation gHomeRotation;
integer  gWaitCount = 0; 
float    gMaxVelMag;
integer  gPrimMaterial;

moveTo(vector origin, vector destination) {
    float dist = llVecDist(origin, destination);
    integer passes = llCeil( llLog(dist/10.0) / llLog(2.0) );
    integer i;
    list params = [PRIM_POSITION, destination];
    for (i=0; i<passes; i++) {
        params = (params=[]) + params + params;
    }
    // actually move the prim, now
    llSetPrimitiveParams(params);
}

returnHome()
{
    llSetStatus(STATUS_PHYSICS, FALSE);
    moveTo(llGetPos(),gHomePosition);
    llSetTimerEvent(0);
    llSetRot(gHomeRotation);
}

calculate_velocity()
{
    float velMag = llVecMag(llGetVel());
    if (velMag > gMaxVelMag) {
        gMaxVelMag = velMag;
    }
}

default
{
    state_entry() {
        gHomePosition = llGetPos();
        gHomeRotation = llGetRot();
    }
    on_rez(integer _n) {
        llResetScript();
    }
    touch_start(integer n) {
        gMaxVelMag = 0;
        llSetPrimitiveParams([PRIM_MATERIAL, gPrimMaterial]);
        llSetStatus(STATUS_PHYSICS,TRUE);
        llSetTimerEvent(0.1);
        llResetTime();
        gWaitCount=0;
        gPrimMaterial++;
        if (gPrimMaterial == 7 ) gPrimMaterial = 0;
    }
    timer() {
        calculate_velocity();
        gWaitCount++;
        if (gWaitCount > 100) { // 10 seconds
            string type = llList2String( gMaterialTypes, gPrimMaterial-1 );
            llOwnerSay(type+" reached maximum velocity of "+(string)gMaxVelMag+
                       " and traveled "+(string)llVecDist(llGetPos(), gHomePosition)+" meters.");
            returnHome();
        }
    }
}

See also: constants

|
PRIM_MATERIAL_STONE integer 0 m=3 s3=colspan="4" c=stone
PRIM_MATERIAL_METAL integer 1 m=3 s3=colspan="4" c=metal
PRIM_MATERIAL_GLASS integer 2 m=3 s3=colspan="4" c=glass
PRIM_MATERIAL_WOOD integer 3 m=3 s3=colspan="4" c=wood
PRIM_MATERIAL_FLESH integer 4 m=3 s3=colspan="4" c=flesh
PRIM_MATERIAL_PLASTIC integer 5 m=3 s3=colspan="4" c=plastic
PRIM_MATERIAL_RUBBER integer 6 m=3 s3=colspan="4" c=rubber
PRIM_MATERIAL_LIGHT integer 7 b= e= c=light, DEPRECATED: Looks the same as [ PRIM_FULLBRIGHT, ALL_SIDES, TRUE ]
material Flags Description Friction Restitution
0.8 0.4
0.3 0.4
0.2 0.7
0.6 0.5
0.9 0.3
0.4 0.7
0.9 0.9
light, DEPRECATED: Looks the same as [ PRIM_FULLBRIGHT, ALL_SIDES, TRUE ] 0.6 0.5

See also: functions

See also: events

Shared wiki helpers

The original page also injects shared parameter notes, caveats or issue information through these helpers. Their conditional MediaWiki logic is not reproduced here; inspect the preserved helper source for additional material.

Template:LSL PrimitiveParam Categorize

Original shared helper source (conditional wiki logic is not evaluated)
{{#if:{{#pos:{{#var:moded}}|r}}{{#pos:{{#var:moded}}|u}}||{{#vardefine:hidden-text|{{#var:hidden-text}}
{{#ifexist:Template:LSLC{{#var:lang}}|
 {{LSLC{{#var:lang}}|PrimitiveParams}}
 {{LSLC{{#var:lang}}|PrimitiveParams/{{{1}}}}}
 {{LSLC{{#var:lang}}|{{{1}}}}}
|
 {{LSLC|PrimitiveParams{{#var:lang}}}}
 {{LSLC|PrimitiveParams/{{{1}}}{{#var:lang}}}}
 {{LSLC|{{{1}}}{{#var:lang}}}}
}}
}}}}
Original wiki source

Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.