Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How to make a script repeat

Persian Chevalier
Registered User
Join date: 8 Jan 2007
Posts: 68
03-14-2008 17:11
Hi. First of all, I know absolutely nothing about scripts. I have been reading and trying to follow and have played with a small script to get it to do a rotation and reverse rotation. I have seen some of the other requests, but it is all greek to me; I just don't understand. I have come up with this script to do what I want, but it does it once or twice (if I put it in twice) and then just rotates the one way.

How can I get it to keep going forward and then back. Thanks for any help.

(php)
default
{
state_entry()
{
llTargetOmega(<0,0,1>, 2, 2);
llSleep(2.0);
llTargetOmega(<0,0,1>, -2, -2);
llSleep(2.0);
llTargetOmega(<0,0,1>, 2, 2);
llSleep(2.0);
llTargetOmega(<0,0,1>, -2, -2);
}
}
(/php)
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
03-14-2008 17:15
I suggest trying a timer: http://www.lslwiki.net/lslwiki/wakka.php?wakka=timer
Persian Chevalier
Registered User
Join date: 8 Jan 2007
Posts: 68
03-14-2008 17:39
Hi Hewee!!

Thanks!! I read about the timers and fiddled, and I have it working just like I want!!
Bobbyb30 Zohari
SL Mentor Coach
Join date: 11 Nov 2006
Posts: 466
03-14-2008 17:52
Oh don't use a timer unless you have to. Instead use a while, do while, or for loop.
_____________________
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
03-14-2008 18:23
From: Bobbyb30 Zohari
Oh don't use a timer unless you have to. Instead use a while, do while, or for loop.

uhm why?
the timer is much more stable than sleep, and doesn't lock out other events ( like touch to start and stop) while it's working as a do/while/for loop would

another thing that could be changed is instead of reversing the spinrate and gain, reverse the axis, the script would end up looking like
CODE

vector gRadAxis = <0.0, 0.0, 1.0>; //-- remeber this is in radians so PI = 180deg
float cConstant = 2.0; //-- since you use it for the seconds spinrate and gain

default{
state_entry(){
llSetTimerEvent( cConstant );
}

timer(){
llSetTargetOmega( gRadAxis, cConstant, cConstant );
gRadAxis = -gRadAxis
}
}
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -