Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Stupid Linked Door Script Question

Rusalka Renoir
Registered User
Join date: 25 Jan 2007
Posts: 45
03-15-2007 00:36
Hi. Newbie scriptor/builder here.

I've managed to cobble together a door script I like, works perfectly. But I would really like to be able to make it work with double doors so that both doors are linked together and open together at the same time. Now, before you ask, I have spent hours and hours reading everything I can find - and I've played with the pertinent portion of the Timeless Door Script. But I just can't get it to work. I know how to link the two doors together. What I can't figure out is how to click on one door and make them both open seperately but together (instead of not at all or as one big hinge). Can someone give me some simply explained help with making this script work to do what I want?

// DOOR SCRIPT

float CLOSE_TIME = 5.0;

integer DIR = -1;

integer OPEN = 1;
integer CLOSE = 2;

vector mypos;

door(integer A) {
rotation rot;
rotation delta;

llSetTimerEvent(0);

if ( A == OPEN ) {

rot = llGetRot();
delta = llEuler2Rot(<0, 0, -DIR * PI_BY_TWO>;);
rot = delta * rot;
llSetRot(rot);

} else if ( A == CLOSE) {
rot = llGetRot();
delta = llEuler2Rot(<0, 0, DIR * PI_BY_TWO>;);
rot = delta * rot;
llSetRot(rot);

}
}


default {
on_rez(integer B) {
llResetScript();
}

state_entry() {
mypos = llGetPos();
}

touch_start(integer total_number) {
door(OPEN);

state is_open;
}

moving_end() {
mypos = llGetPos();
}
}

state is_open {
state_entry() {
llSetTimerEvent(CLOSE_TIME);
}

touch_start(integer num) {
door(CLOSE);

llSetPos(mypos);

state default;
}

timer() {
door(CLOSE);

llSetPos(mypos);

state default;
}

moving_start() {
door(CLOSE);

state default;
}
}
Lightwave Valkyrie
Registered User
Join date: 30 Jan 2004
Posts: 666
03-15-2007 04:02
i would add a touch llMessageLinked in each touch event, and a link_message event in each script same as the touch event in each state.
-LW
_____________________
L$ is the root of all evil
videos work! thanks SL :)
Rusalka Renoir
Registered User
Join date: 25 Jan 2007
Posts: 45
Thanks
03-15-2007 12:13
I'm figuring something like that, but frankly I can't figure out the proper syntax for the llMessageLinked and link_message stuff. Can you give me an example?
Lightwave Valkyrie
Registered User
Join date: 30 Jan 2004
Posts: 666
03-15-2007 15:32
to sent link message:
CODE
touch_start(integer total_number)
{
llMessageLinked(LINK_SET, 0, "open", "");
}


to receive message:
CODE
link_message(integer sender, integer num, string message, key id) 
{
if (message == "open")
{
// dostuff
} else if (message == "close")
{
// dostuff
}

}

-LW
_____________________
L$ is the root of all evil
videos work! thanks SL :)
Rusalka Renoir
Registered User
Join date: 25 Jan 2007
Posts: 45
03-15-2007 17:26
Thank you for the help so far. Haven't gotten it to work yet, but I'm still banging away. :-)