Difference between revisions of "LlSetScale"

From Second Life Wiki
Jump to navigation Jump to search
m (lsl code tagging)
m (Replaced old <LSL> block with <source lang="lsl2">)
 
(14 intermediate revisions by 8 users not shown)
Line 2: Line 2:
|func_id=47|func_sleep=0.0|func_energy=10.0
|func_id=47|func_sleep=0.0|func_energy=10.0
|func=llSetScale
|func=llSetScale
|p1_type=vector|p1_name=scale|p1_desc
|p1_type=vector|p1_name=size|p1_desc
|func_desc=Sets the scale of the prim according to '''scale'''
|func_desc=Sets the size of the prim according to {{LSLP|size}}
|func_footnote='''x''', '''y''' & '''z''' components of '''scale''' need to be in the range [0.01, 10.0], if they are out of the range they are rounded to the nearest endpoint.
|func_footnote=The components of {{LSLP|size}} ({{LSLP|x}}, {{LSLP|y}} & {{LSLP|z}}) each need to be in the range {{Interval|center=component|gte=0.01|lte=64.0}}{{Footnote|handle=interval}}, if they are out of the range they are rounded to the nearest endpoint.
|spec
|spec
|caveats=This function only changes the scale of the ''prim'' that the script is in. '''Not''' the entire object.
|caveats=
*This function only changes the size of the ''prim'' that the script is in. '''Not''' the entire object.
*If the prim is part of a link set, rescaling will fail if the new size is too large or small to satisfy the [[Linkability Rules|linkability rules]].
*Does not work on [[STATUS_PHYSICS|physical]] prims.
|constants
|constants
|examples=
|examples=
<lsl>
<source lang="lsl2">
//A basic door that opens and closes when an avatar colides with it.
//A basic door that opens and closes when an avatar collides with it.
//Not very effective, as it would be better to use llSetStatus(STATUS_PHANTOM, 1)...
//Not very effective, as it would be better to use llSetStatus(STATUS_PHANTOM, 1)...
//But, it works.
//But, it works.
Line 19: Line 22:
     }
     }
     collision_start(integer i) {
     collision_start(integer i) {
           llSetScale(<.1, .1, .1>); //Shrink
           llSetScale(<0.1, 0.1, 0.1>); //Shrink
           llSetPos(llGetPos() + <0,0,10>); //Hide us
           llSetPos(llGetPos() + <0.0,0.0,10.0>); //Hide us
           llSetTimerEvent(3);
           llSetTimerEvent(3.0);
     }
     }
     timer() {
     timer() {
           llSetTimerEvent(0);
           llSetTimerEvent(0.0);
           llSetScale(startingSize); //Go back to normal size
           llSetScale(startingSize); //Go back to normal size
           llSetPos(llGetPos() - <0,0,10>); //And where we started
           llSetPos(llGetPos() - <0.0,0.0,10.0>); //And where we started
     }
     }
} //Code by Xaviar Czervik.
} //Code by Xaviar Czervik.
</lsl>
</source>
 
'''Curtain/Door script'''
 
For a flexible curtain or door script using llSetScale(), see [[http://wiki.secondlife.com/wiki/Curtain_script]]
 
|helpers
|helpers
|also_functions={{LSL DefineRow||[[llGetScale]]|Gets the prims size}}
|also_functions={{LSL DefineRow||[[llGetScale]]|Gets the prims size}}
{{LSL DefineRow||[[llScaleByFactor]]|Uniformly rescale a linkset}}
{{LSL DefineRow||[[llSetPrimitiveParams]]|Sets prims attributes}}
{{LSL DefineRow||[[llSetPrimitiveParams]]|Sets prims attributes}}
{{LSL DefineRow||[[llGetPrimitiveParams]]|Gets prims attributes}}
{{LSL DefineRow||[[llGetPrimitiveParams]]|Gets prims attributes}}

Latest revision as of 13:08, 22 January 2015

Summary

Function: llSetScale( vector size );
0.0 Forced Delay
10.0 Energy

Sets the size of the prim according to size

• vector size

The components of size (x, y & z) each need to be in the range [0.01, 64.0][1], if they are out of the range they are rounded to the nearest endpoint.

Caveats

  • This function only changes the size of the prim that the script is in. Not the entire object.
  • If the prim is part of a link set, rescaling will fail if the new size is too large or small to satisfy the linkability rules.
  • Does not work on physical prims.

Examples

//A basic door that opens and closes when an avatar collides with it.
//Not very effective, as it would be better to use llSetStatus(STATUS_PHANTOM, 1)...
//But, it works.
vector startingSize;
default {
     state_entry() {
          startingSize = llGetScale();
     }
     collision_start(integer i) {
          llSetScale(<0.1, 0.1, 0.1>); //Shrink
          llSetPos(llGetPos() + <0.0,0.0,10.0>); //Hide us
          llSetTimerEvent(3.0);
     }
     timer() {
          llSetTimerEvent(0.0);
          llSetScale(startingSize); //Go back to normal size
          llSetPos(llGetPos() - <0.0,0.0,10.0>); //And where we started
     }
} //Code by Xaviar Czervik.

Curtain/Door script

For a flexible curtain or door script using llSetScale(), see [[1]]

See Also

Functions

•  llGetScale Gets the prims size
•  llScaleByFactor Uniformly rescale a linkset
•  llSetPrimitiveParams Sets prims attributes
•  llGetPrimitiveParams Gets prims attributes

Deep Notes

Footnotes

  1. ^ The ranges in this article are written in Interval Notation.

Signature

function void llSetScale( vector size );