|
Nerolus Mosienko
Registered User
Join date: 3 Aug 2006
Posts: 145
|
02-19-2007 22:42
Hello, I'm making an industrial elevator (which works). Now I'm moving onto the doors. I've got two doors scripted so you click them, one moves up, one moves down. They meet in the middle. That works fine. The door code is open source. I'm trying to make it so I can click the top door (or either door, it does not matter, they both contain the same script) and have both doors open at the same time. I thought I could do this by making the doors listen and talk on a channel, and having the first door speak to the second and tell it to open when the first door was clicked. I've tried many times, used different scripts, mixed and matched. No luck =/ EDIT:: Also if anyone knows how to change the speed at which these doors open, that would be AWESOME! Any help is greatly appreciated! This is the script: //Sliding Door v4 //Works when linked //by Kayla Stonecutter
//How far in meters to travel in each direction. Two or all three can be used for angled movement //NOTE: when linked, this is relative to the root prim //Positive = move north, negative = move south float NorthSouth = 0.0; //Positive = move east, negative = move west float EastWest = 1.0; //Positive = move up, negative = move down float UpDown = 0.0;
//The amount in seconds to stay open, set to 0 to not autoclose float Timer = 15.0;
//Sound to play on open, either a UUID or a name in the door contents //if a name, it must be exact. Leave at "" for no sound string OpenSound = "cb340647-9680-dd5e-49c0-86edfa01b3ac";
//Volume to play open sound, 0.0 is same as no sound, 1.0 is max float OpenVol = 1.0;
//Sound to play on close, either a UUID or a name in the door contents //if a name, it must be exact. Leave at "" for no sound string CloseSound = "e7ff1054-003d-d134-66be-207573f2b535";
//Volume to play close sound, 0.0 is same as no sound, 1.0 is max float CloseVol = 1.0;
//misc variables vector Pos; vector Offset; integer Open; integer x;
default { state_entry() { Offset = <EastWest, NorthSouth, UpDown>; } touch_start(integer num) { for(x = 0; x < num; x++) { Open = !Open; if(Open) { Pos = llGetLocalPos(); if(OpenSound != "") llTriggerSound(OpenSound, OpenVol); llSetPos(Pos + Offset); llSetTimerEvent(Timer); }else{ if(CloseSound != "") llTriggerSound(CloseSound, CloseVol); llSetPos(Pos); llSetTimerEvent(0); } } } on_rez(integer param) { llResetScript(); } moving_end() { if(Open) { Open = 0; llSetTimerEvent(0.0); } } timer() { if(CloseSound != "") llTriggerSound(CloseSound, CloseVol); llSetPos(Pos); llSetTimerEvent(0); Open = 0; } }
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
02-20-2007 02:00
Thats exactly how you should do it. One thing though, your code at teh moment will open/close for every toucher so if two peopel touch it near simultaneously it will open then immediately close. It only really needs to process one touch not all of them. The following is a Newgyised version. It shoudl work but not been into SL to Test. I've moved the common open/clsoe code into functions and then called as appropriate. The extra Open = lines are to ensure that when it hears the command it will synch up. //Sliding Door v4 //Works when linked //by Kayla Stonecutter
//How far in meters to travel in each direction. Two or all three can be used for angled movement //NOTE: when linked, this is relative to the root prim //Positive = move north, negative = move south float NorthSouth = 0.0; //Positive = move east, negative = move west float EastWest = 1.0; //Positive = move up, negative = move down float UpDown = 0.0;
//The amount in seconds to stay open, set to 0 to not autoclose float Timer = 15.0;
//Sound to play on open, either a UUID or a name in the door contents //if a name, it must be exact. Leave at "" for no sound string OpenSound = "cb340647-9680-dd5e-49c0-86edfa01b3ac";
//Volume to play open sound, 0.0 is same as no sound, 1.0 is max float OpenVol = 1.0;
//Sound to play on close, either a UUID or a name in the door contents //if a name, it must be exact. Leave at "" for no sound string CloseSound = "e7ff1054-003d-d134-66be-207573f2b535";
//Volume to play close sound, 0.0 is same as no sound, 1.0 is max float CloseVol = 1.0;
integer DoorChannel = -123456; string CLOSE = "CLOSE"; string OPEN = "OPEN";
//misc variables vector Pos; vector Offset; integer Open;
OpenDoor() { Pos = llGetLocalPos(); if(OpenSound != "") llTriggerSound(OpenSound, OpenVol); llSetPos(Pos + Offset); llSetTimerEvent(Timer); llSay(DoorChannel,OPEN); Open = TRUE; }
CloseDoor() { if(CloseSound != "") llTriggerSound(CloseSound, CloseVol); llSetPos(Pos); llSetTimerEvent(0); llSay(DoorChannel,CLOSE); Open = FALSE; }
default { state_entry() { Offset = <EastWest, NorthSouth, UpDown>; llListen(DoorChannel,"","",""); Open = FALSE; } touch_start(integer num) { Open = !Open; if(Open) { OpenDoor(); } else { CloseDoor(); } } listen( integer channel, string name, key id, string message ) { if(CLOSE == message) { if(Open)CloseDoor(); } else if(OPEN == message) { if(!Open)OpenDoor(); } }
on_rez(integer param) { llResetScript(); } moving_end() { if(Open) { Open = FALSE; llSetTimerEvent(0.0); } } timer() { CloseDoor(); } }
EDIT: Remember llSay only works at approx 20m for anything longer you need llShout
|