Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Assistance with Rotation (in a project)

Petra Tilling
Registered User
Join date: 2 Nov 2006
Posts: 6
01-17-2007 21:15
Hello All,
This LSL is sending me into frustrated befuddlement so I am reaching out for help. I would like to build a box with a lid that opens and closes (currently using a Door script with some success), and a cilindar that turns inside (curently using a free rotation script with little success).

Problem:
- I cant link all of the peices together without mixing up scrits (peices moving that souldn't & vise-versa)
- I can get the cilendar to turn but only in one possition. I would like to be able to rotate the box and have the rotation remain stable (turning, not spinning around another axis).
- The door script that i'm using to open and close the lid will change for no reason known to myself. It also seems to be more than i need with all of the locking features and such.

See, its really is not complex, but when I try to read the wiki or posts on scripts, my brain just shuts down (no I'm not a blonde) : )

Thank you for reading this through and thank you even more for your help. I would be happy to meet you in SL to show you what i'm working on if that would help.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-18-2007 02:37
From: Petra Tilling
Hello All,
This LSL is sending me into frustrated befuddlement so I am reaching out for help. I would like to build a box with a lid that opens and closes (currently using a Door script with some success), and a cilindar that turns inside (curently using a free rotation script with little success).

Problem:
- I cant link all of the peices together without mixing up scrits (peices moving that souldn't & vise-versa)
- I can get the cilendar to turn but only in one possition. I would like to be able to rotate the box and have the rotation remain stable (turning, not spinning around another axis).
- The door script that i'm using to open and close the lid will change for no reason known to myself. It also seems to be more than i need with all of the locking features and such.

See, its really is not complex, but when I try to read the wiki or posts on scripts, my brain just shuts down (no I'm not a blonde) : )

Thank you for reading this through and thank you even more for your help. I would be happy to meet you in SL to show you what i'm working on if that would help.


It would be easier to help if we could see your scripts, but it sounds like the scripts you have picked up are not taking into account the local rotation of the object.
Petra Tilling
Registered User
Join date: 2 Nov 2006
Posts: 6
Scripts
01-18-2007 06:12
The rotation script:

default
{
state_entry()
{
llTargetOmega(<1,0,0>,0.2,PI);
}

}


Door script:

// If door is locked, the name of the avatar who loc

// If door is not locked, the empty string ("";).yhes

string gLockedBy = "";

// This number must match the channel number of the lock
// and unlock objects you want to use. If multiple doors
// have the same channel, then a single lock can lock all of
// them at once.
integer gLockChannel = 243;

default
{
state_entry()
{
llSay(0, "Door 1.0";);
llListen(gLockChannel, "", NULL_KEY, "";);
state closed;
}
}

state closed
{
listen(integer channel, string name, key id, string message)
{
if (channel == gLockChannel)
{
if (message == "";)
{
gLockedBy = "";
//llTriggerSound("door unlock", 10.0);
llSay(0, "unlocked";);
}
else
{
gLockedBy = message;
//llTriggerSound("door lock", 10.0);
llSay(0, "locked";);
}
}
}

touch_start(integer total_number)
{
string name = llDetectedName(0);
if (name == gLockedBy || gLockedBy == "";)
{
llTriggerSound("Door close", 0.5);

rotation rot = llGetRot();
rotation delta = llEuler2Rot(<0,0,PI/8>;);
rot = delta * rot;
llSetRot(rot);
llSleep(0.25);
rot = delta * rot;
llSetRot(rot);
state open;
}
else
{
llTriggerSound("Door knock", 0.5);
}
}
}

state open
{
touch_start(integer num)
{
llTriggerSound("Door close", 0.5);

rotation rot = llGetRot();
rotation delta = llEuler2Rot(<0,0,-PI/8>;);
rot = delta * rot;
llSetRot(rot);

llSleep(0.25);
rot = delta * rot;
llSetRot(rot);

state closed;
}
}


I'm sry I dont know how to put these in little windows.
Thank you for any help you can provide : )
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-18-2007 06:44
I expected as much with the rotation.
llTargetOmega doenst handle being moved or rotated without being reset. Adding a script reset on moving end may cure the problem but moving_end is not triggered for a rotation so you may have to fiddle abit!


To post in code block use the PHP tags [ PHP ] and [ /PHP ] without any spaces.


CODE

default
{
state_entry()
{
llTargetOmega(<1,0,0>,0.2,PI);
}

moving_end()
{
llResetScript();
}

}


That door script is a huge over kill for what you want.
Below is a pared down version, no lock or chat activation but I have left the sound in.

CODE

// Simplified Door Script
// Amount is the amount of rotation to apply in Radians
float Amount = 0.3927; // PI / 8 or 22.5 Degrees
string Sound = "Door close";

default
{
state_entry()
{
}

touch_start(integer total_number)
{
if(Sound <> "")
llTriggerSound(Sound, 0.5);

rotation rot = llGetRot();
rotation delta = llEuler2Rot(<0,0,Amount>);
rot = delta * rot;
llSetRot(rot);
llSleep(0.25);
rot = delta * rot;
llSetRot(rot);
Amount = -Amount;
}

}
Snakeye Plisskin
Registered User
Join date: 8 Apr 2005
Posts: 153
01-18-2007 07:17
For a box with a lid, I would use llGetLocalRot & llSetLocalRotation so you can link the lid to the box.
Petra Tilling
Registered User
Join date: 2 Nov 2006
Posts: 6
Thank you both, but...
01-18-2007 17:42
Thank you Newgate for trying to help out. Unfortunatly, the rotation script is not working out and the door script is coming up with a syntax error. Thank you also Snakeye, but I'm not really sure what GETLOCALROT or SETLOCALROT means or how to use them. Do you know of any people I can go to... is there some kind of service store or someone I can pay to help me out (in SL)?

Any suggestions would be great. Thanks All : )
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-19-2007 00:29
From: Petra Tilling
Thank you Newgate for trying to help out. Unfortunatly, the rotation script is not working out and the door script is coming up with a syntax error. Thank you also Snakeye, but I'm not really sure what GETLOCALROT or SETLOCALROT means or how to use them. Do you know of any people I can go to... is there some kind of service store or someone I can pay to help me out (in SL)?

Any suggestions would be great. Thanks All : )


hmm, give us a bit more of a clue as to whats not working out and what the syntax error is and we can try to help a bit more. Code should compile clean but you never know with me :)

llGetLocalRot and llSetLocalRot are two lsl functions for getting and setting the rotation of a linked prim relative to the root prim.
Petra Tilling
Registered User
Join date: 2 Nov 2006
Posts: 6
ok...
01-19-2007 06:27
thx for hanging in there with me...
ok:
- I'm getting a syntax error for the door script on lines (13 & 18)
not sure if i should have entered somthing in those lines, they look like they need something, but what do i know : )
- the rotation script is giving me the same result as before. I think I might need the SETLOC or GETLOC thing, because I still cant link anything together and if I rotate the box, the cilindar begins turning on another axis.

I was hoping to include a picture of the box, but I couldnt figure out how to do that either : (
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
Ooops!
01-19-2007 14:29
From: Petra Tilling
thx for hanging in there with me...
ok:
- I'm getting a syntax error for the door script on lines (13 & 18)
not sure if i should have entered somthing in those lines, they look like they need something, but what do i know : )
- the rotation script is giving me the same result as before. I think I might need the SETLOC or GETLOC thing, because I still cant link anything together and if I rotate the box, the cilindar begins turning on another axis.

I was hoping to include a picture of the box, but I couldnt figure out how to do that either : (


My mistake, the door script was complaining about line 13 column 18. <> should be !=
I've been having to write in VB this week and it must have slipped in...

lslint didnt pick this up for some reason.

CODE

// Simplified Door Script
// Amount is the amount of rotation to apply in Radians
float Amount = 0.3927; // PI / 8 or 22.5 Degrees
string Sound = "Door close";

default
{
state_entry()
{
}

touch_start(integer total_number)
{
if(Sound != "")
llTriggerSound(Sound, 0.5);

rotation rot = llGetRot();
rotation delta = llEuler2Rot(<0,0,Amount>);
rot = delta * rot;
llSetRot(rot);
llSleep(0.25);
rot = delta * rot;
llSetRot(rot);
Amount = -Amount;
}

}


llTargetOmega is a cleint side effect which I think is why it gives the weird result. The prim is rotating in world axis not relative to its local rotation. However ifd thsi prim is a child prim then use llSetlocalRot instead. its will require atime but should be exactly what you need.
Petra Tilling
Registered User
Join date: 2 Nov 2006
Posts: 6
Thank you
01-21-2007 10:31
Thanks so much.. that door script works well : )