Hi Marlon,
this is my version of "slowing down" the actions of your script.
The bones of it is taking the hole parameter of the torus and replacing it with a variable float "hole" and graduating the value of hole slowly thru the use of a "While" loop.
This code seems to behave the same without the llSleep because of the lag time involved, it wont move any faster (in my simulator) but it can be slowed down by increasing the llSleep time. To change the speed, play with the llSleep value and the value of 0.05 in these parts [hole=hole-0.05;] and [hole=hole+0.05;]
{L_CODE}:
integer g_OpenNow; // True (1) if iris is 'open' now
float hole;
default
{
on_rez(integer param)
{
llResetScript();
}
state_entry()
{
if (g_OpenNow == TRUE) // Prim is in open state, so calculate new 'closed' size
{
hole = 0.05;// fix iris open
state WaitToClose;
}
else // Prim is in a closed (or undefined state), so calculate new 'open' size
{
hole=0.5;// fix iris closed
g_OpenNow = FALSE;
state WaitToOpen;
}
}
}
state WaitToClose // Iris is Open, and waiting to close
{
touch_start(integer total_number)
{
while (hole<0.55)
{
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, hole, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
hole=hole+0.05;
llSleep( 0.01);
}
g_OpenNow = FALSE;
state WaitToOpen;
}
}
state WaitToOpen // Iris is closed, and waiting to open
{
touch_start(integer total_number)
{
while (hole>0.05)
{
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, hole, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
hole=hole-0.05;
llSleep( 0.01);
}
g_OpenNow = TRUE;
state WaitToClose;
}
}
what you were trying to do in VB looks like this in LSL
{L_CODE}:
float a = 0.5;
while (a > 0.05)// keep doing whats inside {} until "a" reaches 0.05
{
<do stuff with "a" here;>
a = a - 0.05; //increment "a" with each itteration
llSleep(0.1);//script sleeps for 0.1 second
}// now retest the "while" condition to see if its been met, if so move on, if not loop again
This may not be the best or most efficient way of doing this but it is the way I would do it, no warranty or responsibility accepted if it causes your iris to tear away from the fabric of your universe and take on a life of its own and eat up all your cookies.
mmmmcookies.