Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

IF problem!

Nicola Samiam
xoxox
Join date: 22 Oct 2004
Posts: 142
06-28-2005 11:24
Hi!
A newbie question I'm sure, but I want to allow only two people to open a door. Here's the script for one person, but my question is, how can I add another person. I guess I want a nested If?, but I'm not sure of the syntax!
Any help gratefully received! Thanks!

string name = llDetectedName(0);
if (name=="Nicola Samiam" )

{

llTriggerSound("Door open", 5.0);

rotation rot = llGetRot();
rotation delta = llEuler2Rot(<0,0,PI/4>;);
rot = delta * rot;
llSetRot(rot);
llSleep(0.25);
rot = delta * rot;
llSetRot(rot);



state open;
}
else
Zapoteth Zaius
Is back
Join date: 14 Feb 2004
Posts: 5,634
06-28-2005 11:28
From: Nicola Samiam
Hi!
A newbie question I'm sure, but I want to allow only two people to open a door. Here's the script for one person, but my question is, how can I add another person. I guess I want a nested If?, but I'm not sure of the syntax!
Any help gratefully received! Thanks!

string name = llDetectedName(0);
if (name=="Nicola Samiam" )

{

llTriggerSound("Door open", 5.0);

rotation rot = llGetRot();
rotation delta = llEuler2Rot(<0,0,PI/4>;);
rot = delta * rot;
llSetRot(rot);
llSleep(0.25);
rot = delta * rot;
llSetRot(rot);



state open;
}
else


I think you can just add another IF thingy-ma-jig.. You can tell I'm not a scripter huh?

CODE

string name = llDetectedName(0);
if (name=="Nicola Samiam" )

{

llTriggerSound("Door open", 5.0);

rotation rot = llGetRot();
rotation delta = llEuler2Rot(<0,0,PI/4>);
rot = delta * rot;
llSetRot(rot);
llSleep(0.25);
rot = delta * rot;
llSetRot(rot);



state open;
}

if (name=="OTHER NAME" )

{

llTriggerSound("Door open", 5.0);

rotation rot = llGetRot();
rotation delta = llEuler2Rot(<0,0,PI/4>);
rot = delta * rot;
llSetRot(rot);
llSleep(0.25);
rot = delta * rot;
llSetRot(rot);



state open;
}
else
_____________________
I have the right to remain silent. Anything I say will be misquoted and used against me.
---------------
Zapoteth Designs, Temotu (100,50)
---------------
Vortex Saito
Quintzee Creator
Join date: 10 Sep 2004
Posts: 73
06-28-2005 11:40
In an if statement, you can use also the following :

&& for AND
|| for OR

So yours would be :

if (name=="Nicola Samiam" || name=="other name";)
_____________________
I don't care I am a lemming, I am NOT going !!!!

secondlife://puea/54/15
Jon Marlin
Builder, Coder, RL & SL
Join date: 10 Mar 2005
Posts: 297
06-28-2005 11:40
A better version would be:

CODE
   string name = llDetectedName(0);
if (name=="Nicola Samiam" || name == "Jon Marlin")

{

llTriggerSound("Door open", 5.0);

rotation rot = llGetRot();
rotation delta = llEuler2Rot(<0,0,PI/4>);
rot = delta * rot;
llSetRot(rot);
llSleep(0.25);
rot = delta * rot;
llSetRot(rot);



state open;
}
else


Of course, if you wanted to get fancy, you could have a list of allowed names, with a touch-based chat interface to add/remove/list names...

- Jon
_____________________
Come visit Marlin Engineering at Horseshoe (222, 26) to see my line of flying vehicles.
Nicola Samiam
xoxox
Join date: 22 Oct 2004
Posts: 142
06-28-2005 11:44
Thanks guys!
It was the OR symbol I was looking for I think! (I tried typing OR, but it didn't work. Derr!)