Nexeus Fatale
DJ Nexeus
Join date: 28 Aug 2004
Posts: 128
|
03-21-2005 06:10
I have a sliding door script, but I want to see if I can link it to houses I'm building, without having the entire building SLIDE in one direction. I Figured, I could unlike everthing, slide the door and link everything, but that would seem a bit to cumbersome. here is the door script, does anyone have any ideas? //Door Script - Nexeus Fatale //Idea originally made by Rhombur Volos
//A variable that is set to 0, indicates if the door is open (1) or closed (0) integer dHandle = 0;
//This is the control for your door to slide open or close vector dSlide = <0,2.5,0>;
//Opens the door, set the handle to 1 doorOpen() { llSetPos(llGetPos() + ((dSlide *-1) *llGetRot())); dHandle = 1; }
//Closes the door, set the handle to 0 doorClose() { llSetPos (llGetPos() + (dSlide * llGetRot())); dHandle = 0; }
default { touch_start(integer touches) { if (dHandle == 0) { doorOpen(); } else if (dHandle == 1) { doorClose(); } } }
_____________________
Website: www.nexeusfatale.com [nf_d]: nfd.nexeusfatale.com
|
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
|
03-21-2005 06:18
You can use llSetPos in the door itself, so long as it's not linked as the master. Note llSetPos in this manner bases it off where the root is located. Quick rewrite would look something like this: //This is the control for your door to slide open or close vector dSlide = <0,2.5,0>;
//Opens the door, set the handle to 1 doorOpen() { llSetPos(llGetPos() - llGetRootPosition() + ((dSlide *-1) *llGetRot())); dHandle = 1; }
//Closes the door, set the handle to 0 doorClose() { llSetPos (llGetPos() - llGetRootPosition() + (dSlide * llGetRot())); dHandle = 0; }
default { touch_start(integer touches) { if (dHandle == 0) { doorOpen(); } else if (dHandle == 1) { doorClose(); } } } ... where all I added was llGetRootPosition to your movements. Or rather, subtracted.
_____________________
---
|
Nexeus Fatale
DJ Nexeus
Join date: 28 Aug 2004
Posts: 128
|
03-22-2005 17:12
well that works, but doesn't seem to actually just slide open and closed. The door now seems to move from one point to another, to another... and after a few clicks it returns to it's inital point.
_____________________
Website: www.nexeusfatale.com [nf_d]: nfd.nexeusfatale.com
|
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
|
03-22-2005 18:26
For a smooth effect, you would have to unlink it entirely and use llMoveToTarget
_____________________
---
|
Nexeus Fatale
DJ Nexeus
Join date: 28 Aug 2004
Posts: 128
|
03-23-2005 17:52
Thanks! Although being a newb at this doesn't entirely help.
The first solution you gave me gives me another idea for something, but I'm going to try that another time for another project.
I'll just link them and group them in a box, and see what happens.
Thanks again Jeff!
_____________________
Website: www.nexeusfatale.com [nf_d]: nfd.nexeusfatale.com
|
Racer Plisskin
Rezerator
Join date: 2 Jan 2005
Posts: 147
|
03-23-2005 19:45
Sounds like a variation of a drawer script application to me... I dunno, I'd just do this: integer is_open = FALSE; // assume the door starts out closed float slide_dist = 0.8; // the door slides 80 Cm...
default { state_entry() { }
touch_start(integer null_var) { if ( is_open ) { // then close the door llSetPos(<-slide_dist, 0.0, 0.0> + llGetLocalPos()); is_open = FALSE; } else { // open the doorr llSetPos(<slide_dist, 0.0, 0.0> + llGetLocalPos()); is_open = TRUE; } } }
You just have to 'slide' the door on the correct axis in relation to the root prim of the house. The above example assumes the X axis in relation to the root prim. Easy enough to change that to Y or Z axis if needed. If you want the door to slide at some other angle than 0/90/180/270 on the X, Y or Z plain in relation to the root prim that gets a bit tricky... (I'll leave it up to you to add locks and/or other fancy widgets  ) Racer P.
|