Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rotation script that doesn't reset?

Cahliah Dassin
Registered User
Join date: 10 Sep 2005
Posts: 20
10-09-2005 09:47
You'd think it would be simple - a rotation script that doesn't reset every time someone right-clicks on the object - but I'm having the hardest time finding one.

I'm making a merry-go-round, and I have a script that will let me turn it on/off by touch, but every time -anyone- right-clicks on the object, it snaps back to the starting position, which just doesn't work for something that people are riding.

Any suggestions?
Logan Bauer
Inept Adept
Join date: 13 Jun 2004
Posts: 2,237
10-09-2005 10:40
If you could post the script you're using Cahliah, I'm sure myself or someone else could look at it... It's probably using llTargetOmega which is client-side rotation and I think kinda unavoidable that it's gonna just snap back to the starting position when you toggle on and off- probably would need to remove the TargetOmega and replace it with a different form of rotation to fix this...
Cahliah Dassin
Registered User
Join date: 10 Sep 2005
Posts: 20
Sure thing...
10-09-2005 11:10
The script I'm using is as follows:


// Simple rotation script using targetomega
//
vector axis = <0,0,1>;
//
float spinrate = 1.0;
//
float gain = 1.0;
//
//
// for a discussion on llTargetOmega values see
// http://secondlife.com/badgeo/wakka.php?wakka=llTargetOmega
//
integer on = FALSE;
//
//
// simple switch
// if on turn off
// if off turn on
//
switch()
{
if ( on )
{
llOwnerSay ( "Switching OFF rotation" );
on = FALSE;
llTargetOmega( <0,0,0>,0,0 );
}
else
{
llOwnerSay ( "Switching ON rotation" );
on = TRUE;
llTargetOmega( axis, spinrate, gain );
}
}

//
// At startup rotation is switched on automatically
//
init()
{
switch();
}

default
{
state_entry()
{
init();
}
on_rez( integer param )
{
init();
}
touch_start( integer num )
{
// Uncomment the following lines if you wish only the owner to have
// control over starting and stopping
if ( llDetectedKey(0) != llGetOwner() )
{
return;
}

// Touch to switch on and off
switch();
}
}



Is there a different form of rotation that might work? I'm definitely not the greatest at scripting - I mostly use found scripts.
Thanks. :)
Rodrick Harrington
Registered User
Join date: 9 Jul 2005
Posts: 150
10-09-2005 12:25
You are using client side rotations, which . . . while great for lag on the sim doesn't have the same effect for all viewers, if you want all avatars to see the EXACT same thing for some reason have it actually rotate the object (note: this will increase lag in the area, however slightly)
Cahliah Dassin
Registered User
Join date: 10 Sep 2005
Posts: 20
10-09-2005 12:27
That's what I figured. Is there anyone that can help me figure out how to do this?
Siro Mfume
XD
Join date: 5 Aug 2004
Posts: 747
10-09-2005 18:50
if you want actual rotation, you can either use nonphysics rotation such as llSetRot and configure a timer to rotate in increments; or you can use physics rotation and the myriad of ways people use to rotate things physical (rotational impulses, torque, vehicle api, etc).