Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Drawer scripts

Greg Stewart
Second Life Resident
Join date: 22 Oct 2004
Posts: 8
03-23-2005 14:36
Hi ,
I recently made a very cool stereo system but i cannot get the disk tray to open while linked to the rest of the stereo.
If anyone can shed some light on this plz write about it maybe a script or somthin someone can give me.

if you need to contact me inworld i am Greg Stwart and my Email is [email]gregwat@gmail.com[/email]
Catherine Omega
Geometry Ninja
Join date: 10 Jan 2003
Posts: 2,053
03-23-2005 14:47
In a fully linked object, you'd need to use llSetPrimitiveParams or llSetPos. If your CD tray is more than one prim, you'd need to use link messages. All in all, it's pretty straightforward. If you're unsure what to do, just ask for help.
_____________________
Need scripting help? Visit the LSL Wiki!
Omega Point - Catherine Omega's Blog
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
03-23-2005 14:48
If it's one prim (or even if not), this is doable if you use llSetPos locally. That is, when linked, the child prim moves relative to the master when you use this command.

Compare:
Unlinked: llSetPos(<1,1,1>;);

Now suppose your master object (the stereo) is at <1,0,1> and the tray is at <1,1,1>. Assume the stereo is rotated at <0,0,0,1>, or 0 on X, 0 on Y, 0 on Z:
Linked: llSetPos(<0,1,0> * llGetRootRotation());

Oh yes, and if you want to rotate your stereo around, let's not forget llSetRot(<0,0,0,1> * llGetRootRotation()); Change <0,0,0,1> to the rotation the tray is originally at via llGetRot();

Wiki Links:
http://secondlife.com/badgeo/wakka.php?wakka=llSetPos
http://secondlife.com/badgeo/wakka.php?wakka=llSetRot
http://secondlife.com/badgeo/wakka.php?wakka=llGetRootRotation
http://secondlife.com/badgeo/wakka.php?wakka=llGetRootPosition
_____________________
---
Greg Stewart
Second Life Resident
Join date: 22 Oct 2004
Posts: 8
03-23-2005 14:57
thank you but i was kind of hoping for a script to be typed out on this forum so i could copy an paste LOL

is tht possible?

BTW........the disk tray has 2 other decorative objects attached to it
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
03-23-2005 15:03
"Give a man a fish and he eats for a day. Teach a man to fish, and he eats for a lifetime...."


...

Just kidding! :D

CODE
integer on = FALSE;
touch_start(integer total_number)
{
if(on)
{
llSetPos(<add,position,here> * llGetRootRotation());
llSetLocalRot(<add,rotation,here,ya?> * llGetRootRotation());
}
else
{
llSetPos(<add,position,here> * llGetRootRotation());
llSetLocalRot(<add,rotation,here,ya?> * llGetRootRotation());
}
on = !on;
}
_____________________
---
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
03-23-2005 15:08
I've never had to worry about rotation for child prim position changes with llSetPos. It's always been relative to the root prim.

Is that nessesary and I've just been lucky, or am I missing some other point?

And what about llSetLocalRot?
_____________________
Greg Stewart
Second Life Resident
Join date: 22 Oct 2004
Posts: 8
03-23-2005 15:34
im sorry but tht script sent me a syntax error when i copied it to a script file.
any fixes?
Greg Stewart
Second Life Resident
Join date: 22 Oct 2004
Posts: 8
03-23-2005 16:11
Anyone Plz Give Me A Working Script For This??
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
03-23-2005 16:23
You have to add your own coordinates, Greg. That's as far as I can give you without the raw data.

Jillian: On llSetLocalRot, you're right. The way to get it working is actually llSetLocalRot(<add,rotation,here,ya?> * llGetRootRotation()); I've editted that as such. Additionally, in my brief experience with llSetPos and child prims, I needed to compensate for the rotation of the root prim. Your method may also work - this is something I have less experience with.
_____________________
---
Racer Plisskin
Rezerator
Join date: 2 Jan 2005
Posts: 147
03-23-2005 16:25
Hi Greg,

There is a discussion on this here:

/8/5d/36536/1.html

There are 2 versions of the script. one simple one for a 1 part drawer
and a more complex 'generic' script that can be used for a drawer composed of any number of prims. Simply drop a copy of the script into each part of the drawer (just make sure all parts of the same drawer use the same drawer number).

----

Hi Jeffrey,

While I agree with the sentiment, I find I generaly learn more and faster from a well written example then even the best documentation.

I dunno why, but it's just the way my brain works I guess. I'll get there just the same with the documentation but it's often slow and torturus going where a good example can make me go 'Aha! Euika! I understand what's happening here!' in just a minute or two.

Racer P.
Greg Stewart
Second Life Resident
Join date: 22 Oct 2004
Posts: 8
03-23-2005 18:49
Thx Guys It Works