Difference between revisions of "Curtain script"
Jump to navigation
Jump to search
Kireji Haiku (talk | contribs) (replaced example script with three example scripts, one for each axis.) |
|||
Line 1: | Line 1: | ||
{{LSL Header}} | {{LSL Header}} | ||
== About these scripts: == | |||
Drop these scripts into the prim you want to use as a curtain. The script will change the length of the prim on one of the three axis. There's one script each for x, y and z. | |||
You can use these scripts with any prim type. | |||
== Curtain script to change length on x-axis == | |||
<lsl> | <lsl> | ||
float maxScaleX; | |||
float minScaleX; | |||
float time; | |||
integer direction; | |||
init() | |||
{ | |||
maxScaleX = 4.00; | |||
minScaleX = 0.50; | |||
time = 2.0; | |||
direction = 1; | |||
} | |||
OperateBlind() | |||
{ | |||
vector startScale = llGetScale(); | |||
vector startPos = llGetLocalPos(); | |||
rotation localRot = llGetLocalRot(); | |||
float i; | |||
llResetTime(); | |||
do | |||
{ | |||
i = llGetTime()/time; | |||
if (direction == 1) | |||
llSetLinkPrimitiveParamsFast(LINK_THIS,[ | |||
PRIM_SIZE, <maxScaleX - i*(maxScaleX-minScaleX), startScale.y, startScale.z>, | |||
PRIM_POSITION, startPos + i*<(maxScaleX-minScaleX)*0.5, 0.0, 0.0>*localRot]); | |||
else if (direction == -1) | |||
llSetLinkPrimitiveParamsFast(LINK_THIS,[ | |||
PRIM_SIZE, <minScaleX + i*(maxScaleX-minScaleX), startScale.y, startScale.z>, | |||
PRIM_POSITION, startPos - i*<(maxScaleX-minScaleX)*0.5, 0.0, 0.0>*localRot]); | |||
} | |||
while (llGetTime() < time); | |||
if (direction == 1) | |||
llSetLinkPrimitiveParamsFast(LINK_THIS,[ | |||
PRIM_SIZE, <maxScaleX - i*(maxScaleX-minScaleX), startScale.y, startScale.z>, | |||
PRIM_POSITION, startPos + i*<(maxScaleX-minScaleX)*0.5, 0.0, 0.0>*localRot]); | |||
else if (direction == -1) | |||
llSetLinkPrimitiveParamsFast(LINK_THIS,[ | |||
PRIM_SIZE, <minScaleX + i*(maxScaleX-minScaleX), startScale.y, startScale.z>, | |||
PRIM_POSITION, startPos - i*<(maxScaleX-minScaleX)*0.5, 0.0, 0.0>*localRot]); | |||
direction *= -1; | |||
} | |||
default { | default | ||
state_entry() { | { | ||
state_entry() | |||
{ | |||
init(); | |||
} | } | ||
touch_start(integer | touch_start(integer num_detected) | ||
{ | |||
OperateBlind(); | |||
} | } | ||
} | } | ||
</lsl> | </lsl> | ||
== Curtain script to change length on y-axis == | |||
<lsl> | |||
float maxScaleY; | |||
float minScaleY; | |||
float time; | |||
integer direction; | |||
init() | |||
{ | |||
maxScaleY = 4.00; | |||
minScaleY = 0.50; | |||
time = 2.0; | |||
direction = 1; | |||
} | |||
OperateBlind() | |||
{ | |||
vector startScale = llGetScale(); | |||
vector startPos = llGetLocalPos(); | |||
rotation localRot = llGetLocalRot(); | |||
float i; | |||
llResetTime(); | |||
do | |||
{ | |||
i = llGetTime()/time; | |||
if (direction == 1) | |||
llSetLinkPrimitiveParamsFast(LINK_THIS,[ | |||
PRIM_SIZE, <startScale.x, maxScaleY - i*(maxScaleY-minScaleY), startScale.z>, | |||
PRIM_POSITION, startPos + i*<0.0, (maxScaleY-minScaleY)*0.5, 0.0>*localRot]); | |||
else if (direction == -1) | |||
llSetLinkPrimitiveParamsFast(LINK_THIS,[ | |||
PRIM_SIZE, <startScale.x, minScaleY + i*(maxScaleY-minScaleY), startScale.z>, | |||
PRIM_POSITION, startPos - i*<0.0, (maxScaleY-minScaleY)*0.5, 0.0>*localRot]); | |||
} | |||
while (llGetTime() < time); | |||
if (direction == 1) | |||
llSetLinkPrimitiveParamsFast(LINK_THIS,[ | |||
PRIM_SIZE, <startScale.x, maxScaleY - (maxScaleY-minScaleY), startScale.z>, | |||
PRIM_POSITION, startPos + <0.0, (maxScaleY-minScaleY)*0.5, 0.0>*localRot]); | |||
else if (direction == -1) | |||
llSetLinkPrimitiveParamsFast(LINK_THIS,[ | |||
PRIM_SIZE, <startScale.x, minScaleY + (maxScaleY-minScaleY), startScale.z>, | |||
PRIM_POSITION, startPos - <0.0, (maxScaleY-minScaleY)*0.5, 0.0>*localRot]); | |||
direction *= -1; | |||
} | |||
default | |||
{ | |||
state_entry() | |||
{ | |||
init(); | |||
} | |||
touch_start(integer num_detected) | |||
{ | |||
OperateBlind(); | |||
} | |||
} | |||
</lsl> | |||
== Curtain script to change length on z-axis == | |||
<lsl> | |||
float maxScaleZ; | |||
float minScaleZ; | |||
float time; | |||
integer direction; | |||
init() | |||
{ | |||
maxScaleZ = 4.00; | |||
minScaleZ = 0.50; | |||
time = 2.0; | |||
direction = 1; | |||
} | |||
OperateBlind() | |||
{ | |||
vector startScale = llGetScale(); | |||
vector startPos = llGetLocalPos(); | |||
rotation localRot = llGetLocalRot(); | |||
float i; | |||
llResetTime(); | |||
do | |||
{ | |||
i = llGetTime()/time; | |||
if (direction == 1) | |||
llSetLinkPrimitiveParamsFast(LINK_THIS,[ | |||
PRIM_SIZE, <startScale.x, startScale.y, maxScaleZ - i*(maxScaleZ-minScaleZ)>, | |||
PRIM_POSITION, startPos + i*<0.0, 0.0, (maxScaleZ-minScaleZ)*0.5>*localRot]); | |||
else if (direction == -1) | |||
llSetLinkPrimitiveParamsFast(LINK_THIS,[ | |||
PRIM_SIZE, <startScale.x, startScale.y, minScaleZ + i*(maxScaleZ-minScaleZ)>, | |||
PRIM_POSITION, startPos - i*<0.0, 0.0, (maxScaleZ-minScaleZ)*0.5>*localRot]); | |||
} | |||
while (llGetTime() < time); | |||
if (direction == 1) | |||
llSetLinkPrimitiveParamsFast(LINK_THIS,[ | |||
PRIM_SIZE, <startScale.x, startScale.y, maxScaleZ - (maxScaleZ-minScaleZ)>, | |||
PRIM_POSITION, startPos + <0.0, 0.0, (maxScaleZ-minScaleZ)*0.5>*localRot]); | |||
else if (direction == -1) | |||
llSetLinkPrimitiveParamsFast(LINK_THIS,[ | |||
PRIM_SIZE, <startScale.x, startScale.y, minScaleZ + (maxScaleZ-minScaleZ)>, | |||
PRIM_POSITION, startPos - <0.0, 0.0, (maxScaleZ-minScaleZ)*0.5>*localRot]); | |||
direction *= -1; | |||
} | |||
default | |||
{ | |||
state_entry() | |||
{ | |||
init(); | |||
} | |||
touch_start(integer num_detected) | |||
{ | |||
OperateBlind(); | |||
} | |||
} | |||
</lsl> | |||
{{LSLC|Library}} | {{LSLC|Library}} |
Revision as of 09:19, 17 October 2012
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
About these scripts:
Drop these scripts into the prim you want to use as a curtain. The script will change the length of the prim on one of the three axis. There's one script each for x, y and z.
You can use these scripts with any prim type.
Curtain script to change length on x-axis
<lsl> float maxScaleX; float minScaleX; float time; integer direction;
init() {
maxScaleX = 4.00; minScaleX = 0.50; time = 2.0;
direction = 1;
}
OperateBlind() {
vector startScale = llGetScale(); vector startPos = llGetLocalPos(); rotation localRot = llGetLocalRot(); float i; llResetTime(); do { i = llGetTime()/time; if (direction == 1) llSetLinkPrimitiveParamsFast(LINK_THIS,[ PRIM_SIZE, <maxScaleX - i*(maxScaleX-minScaleX), startScale.y, startScale.z>, PRIM_POSITION, startPos + i*<(maxScaleX-minScaleX)*0.5, 0.0, 0.0>*localRot]); else if (direction == -1) llSetLinkPrimitiveParamsFast(LINK_THIS,[ PRIM_SIZE, <minScaleX + i*(maxScaleX-minScaleX), startScale.y, startScale.z>, PRIM_POSITION, startPos - i*<(maxScaleX-minScaleX)*0.5, 0.0, 0.0>*localRot]); } while (llGetTime() < time); if (direction == 1) llSetLinkPrimitiveParamsFast(LINK_THIS,[ PRIM_SIZE, <maxScaleX - i*(maxScaleX-minScaleX), startScale.y, startScale.z>, PRIM_POSITION, startPos + i*<(maxScaleX-minScaleX)*0.5, 0.0, 0.0>*localRot]); else if (direction == -1) llSetLinkPrimitiveParamsFast(LINK_THIS,[ PRIM_SIZE, <minScaleX + i*(maxScaleX-minScaleX), startScale.y, startScale.z>, PRIM_POSITION, startPos - i*<(maxScaleX-minScaleX)*0.5, 0.0, 0.0>*localRot]); direction *= -1;
}
default {
state_entry() { init(); }
touch_start(integer num_detected) { OperateBlind(); }
} </lsl>
Curtain script to change length on y-axis
<lsl> float maxScaleY; float minScaleY; float time; integer direction;
init() {
maxScaleY = 4.00; minScaleY = 0.50; time = 2.0;
direction = 1;
}
OperateBlind() {
vector startScale = llGetScale(); vector startPos = llGetLocalPos(); rotation localRot = llGetLocalRot(); float i; llResetTime(); do { i = llGetTime()/time; if (direction == 1) llSetLinkPrimitiveParamsFast(LINK_THIS,[ PRIM_SIZE, <startScale.x, maxScaleY - i*(maxScaleY-minScaleY), startScale.z>, PRIM_POSITION, startPos + i*<0.0, (maxScaleY-minScaleY)*0.5, 0.0>*localRot]); else if (direction == -1) llSetLinkPrimitiveParamsFast(LINK_THIS,[ PRIM_SIZE, <startScale.x, minScaleY + i*(maxScaleY-minScaleY), startScale.z>, PRIM_POSITION, startPos - i*<0.0, (maxScaleY-minScaleY)*0.5, 0.0>*localRot]); } while (llGetTime() < time); if (direction == 1) llSetLinkPrimitiveParamsFast(LINK_THIS,[ PRIM_SIZE, <startScale.x, maxScaleY - (maxScaleY-minScaleY), startScale.z>, PRIM_POSITION, startPos + <0.0, (maxScaleY-minScaleY)*0.5, 0.0>*localRot]); else if (direction == -1) llSetLinkPrimitiveParamsFast(LINK_THIS,[ PRIM_SIZE, <startScale.x, minScaleY + (maxScaleY-minScaleY), startScale.z>, PRIM_POSITION, startPos - <0.0, (maxScaleY-minScaleY)*0.5, 0.0>*localRot]); direction *= -1;
}
default {
state_entry() { init(); }
touch_start(integer num_detected) { OperateBlind(); }
} </lsl>
Curtain script to change length on z-axis
<lsl> float maxScaleZ; float minScaleZ; float time; integer direction;
init() {
maxScaleZ = 4.00; minScaleZ = 0.50; time = 2.0;
direction = 1;
}
OperateBlind() {
vector startScale = llGetScale(); vector startPos = llGetLocalPos(); rotation localRot = llGetLocalRot(); float i; llResetTime(); do { i = llGetTime()/time; if (direction == 1) llSetLinkPrimitiveParamsFast(LINK_THIS,[ PRIM_SIZE, <startScale.x, startScale.y, maxScaleZ - i*(maxScaleZ-minScaleZ)>, PRIM_POSITION, startPos + i*<0.0, 0.0, (maxScaleZ-minScaleZ)*0.5>*localRot]); else if (direction == -1) llSetLinkPrimitiveParamsFast(LINK_THIS,[ PRIM_SIZE, <startScale.x, startScale.y, minScaleZ + i*(maxScaleZ-minScaleZ)>, PRIM_POSITION, startPos - i*<0.0, 0.0, (maxScaleZ-minScaleZ)*0.5>*localRot]); } while (llGetTime() < time); if (direction == 1) llSetLinkPrimitiveParamsFast(LINK_THIS,[ PRIM_SIZE, <startScale.x, startScale.y, maxScaleZ - (maxScaleZ-minScaleZ)>, PRIM_POSITION, startPos + <0.0, 0.0, (maxScaleZ-minScaleZ)*0.5>*localRot]); else if (direction == -1) llSetLinkPrimitiveParamsFast(LINK_THIS,[ PRIM_SIZE, <startScale.x, startScale.y, minScaleZ + (maxScaleZ-minScaleZ)>, PRIM_POSITION, startPos - <0.0, 0.0, (maxScaleZ-minScaleZ)*0.5>*localRot]); direction *= -1;
}
default {
state_entry() { init(); }
touch_start(integer num_detected) { OperateBlind(); }
} </lsl>