Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Door with entry list access

Biddily Borst
Registered User
Join date: 1 Aug 2006
Posts: 14
03-08-2007 13:19
I have just started scripting and am completely bamboozled. I would very much appreciate some help adapting a sliding door in my new house to allow me to add names. I bought a door which did what I want, but didn't like the messages and it's non-modifiable so I thought I'd try and do it myself. I am quite happy to set the open/closed vectors for each door myself, but I can't seem to get an access list which works

My sliding door script is

CODE

/////////////////////////////////
//ultra basic sliding door script
//by Kyrah Abattoir
/////////////////////////////////
vector closed = <0, 0, 0>;//XYZ coordinates of the door when closed
vector open = <0, 0, 0>;//XYZ coordinates of the door when open
float time = 5.0;//time before the door close itself
default
{
state_entry()
{
closed = llGetPos();
llSetPos(closed);
llSetText("",<1,1,1>,1.0);//REMOVE THIS LINE
}

touch_start(integer total_number)
{
llSetPos(open);
llSleep(time);
llSetPos(closed);
}
}


All I want is to be able to have a notecard in the door to which I can add names, so if the Avi is on the list the door opens and if it isn't the door stays shut, so I don't have to keep fiddling with the script. I have looked at the Library and tried to do it myself but it's all a bit beyond me, and all the scripts I've tried to adapt (eg Timeless Door) are really too complicated.

I suppose I need a message if the door is locked saying "You are not allowed entry" but it's not essential

Any help would be really appreciated
Thanks!
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-08-2007 14:28
Try this thread for a very simple, hardcoded example.

A notecard facility could easily be added.
Biddily Borst
Registered User
Join date: 1 Aug 2006
Posts: 14
03-08-2007 15:01
Thanks very much for your reply.

I did look at the thread you refer to before, but I wanted to add to the sliding door script which I can use easily, and I found the other script incredibly confusing and too complicated. I just wanted to know how to add an access list via notecard, and how to make the door only open to those people on the access list.

For the time being, I've put in a home security system which teleports people away, but it is a bit brutal, think it would be politer to just have locked doors.
Thanks again
Biddily
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-09-2007 01:38
From: Biddily Borst
Thanks very much for your reply.

I did look at the thread you refer to before, but I wanted to add to the sliding door script which I can use easily, and I found the other script incredibly confusing and too complicated. I just wanted to know how to add an access list via notecard, and how to make the door only open to those people on the access list.

For the time being, I've put in a home security system which teleports people away, but it is a bit brutal, think it would be politer to just have locked doors.
Thanks again
Biddily


You thought that was complex? rofl oh well.

Populating the list from a notecard will require some 'complex' code.
You will need something like the following :

CODE

/////////////////////////////////
//ultra basic sliding door script
//by Kyrah Abattoir
/////////////////////////////////
vector closed = <0, 0, 0>;//XYZ coordinates of the door when closed
vector open = <0, 0, 0>;//XYZ coordinates of the door when open
float time = 5.0;//time before the door close itself

list allowedNames;
string notecard = "Configuration";
integer lineCounter;
key dataRequestID;
//
// helper functions
//

integer AllowEntry(key id)
{
string name = llToLower(llKey2Name(id));
integer iIndex = llListFindList(allowedNames, [ name ]);
// Always allow the owner
if(llGetOwner() == id) iIndex = 9999;

integer result = FALSE;
if(iIndex >= 0) result = TRUE;
return result;

}


Changed(integer change)
{
// Test for a changed inventory
if (change & CHANGED_INVENTORY)
{
llResetScript();
}
else if (change & CHANGED_OWNER)
{
llResetScript();
}
}
//--------------------------------------------------------------------------------
default
{
state_entry()
{
state ReadConfig;
}

on_rez() { llResetScript(); }

changed(integer change) { Changed(change) ; }
}
//--------------------------------------------------------------------------------
state Running
{
state_entry()
{
closed = llGetPos();
llSetPos(closed);
llSetText("",<1,1,1>,1.0);//REMOVE THIS LINE
}

touch_start(integer total_number)
{
key id = llDetectedKey(0);
if(AllowEntry(id))
{
llSetPos(open);
llSleep(time);
llSetPos(closed);
}
else
{
llWhisper(0,"Sorry but only allowed people can open this door");
}
}


changed(integer change) { Changed(change) ; }


}

//--------------------------------------------------------------------------------
state ReadConfig
{
state_entry()
{
lineCounter = 0;
allowedNames = []; // List of Allowed Users
integer itemtype = llGetInventoryType(notecard);
if(INVENTORY_NOTECARD == itemtype)
{
dataRequestID = llGetNotecardLine(notecard, lineCounter);
llSetTimerEvent(10);
}
else
{
llOwnerSay("Error - configuration notecard missing. Owner only operation!");
state open;
}

}

dataserver( key query_id, string data ) // read from the notecard
{
if(query_id == dataRequestID)
{
if (data != EOF)
{
if(llGetSubString(data, 0,0) != ";")
{
allowedNames = (allowedNames = []) + allowedNames + [ llToLower(data) ];
llOwnerSay("Allowing "+data);
}
lineCounter++;
dataRequestID = llGetNotecardLine( notecard, lineCounter );
}
else
{
llSetTimerEvent(0);
state Running;
}
}
}

timer()
{
llOwnerSay("ERROR - Dataserver time out! aborting");
llSetTimerEvent(0);
state Running;
}

on_rez(integer num) { llResetScript(); }

changed(integer change) { Changed(change) ; }

}



I notuice your posted script contains zero vectors for both open and closed was that intentional?

Also be aware that a security system, although brutal, is the only thing that will stop someone by passing a door and enteringa room if they want to.
Biddily Borst
Registered User
Join date: 1 Aug 2006
Posts: 14
03-09-2007 02:43
Newgate you are great! Thanks so much for this. One day maybe I'll understand all the LSL code but for the moment I just wanted to get someone to do it all for me (hahaha!)

It works!!
I have a few comments which may help other people who might want to use this..

I put the vectors at 0 to make it easier for other people to use the script if they wanted.

I cut and pasted the script into one of the doors and it bought up a syntax error around the on_rez () area - it seemed not to like the empty brackets. I tried typing in (integer num) is that the right thing to do? I've put the few lines round the code here so you can see where I mean - it was line 51 col 12 in my script.


CODE

//
default
{
state_entry()
{
state ReadConfig;
}

on_rez () { llResetScript(); }

changed(integer change) { Changed(change) ; }
}



When I typed in integer num the script then gave me an error in 102,22, round the "state open" - the bit of code is :

CODE

//
else
{ llOwnerSay("Error - configuration notecard missing. Owner only operation!");
state open;
}


says ERROR - name not defined within scope
I took out the whole bit of script, and everything saved fine. Don't know what effect this might have.

Anyway, for anybody who wants to use this brilliant script from Newgate, here's how I made it work for me:

1. Make a door, work out its closed and open positions and get the XYZ vector coords for these
2. Put all the AVI names of people you want to allow to open the door on a notecard, call it "Configuration" and save it in the contents tab of the door
3. Paste the full script as below into a new script.
4. Put separate script with unique door coords and the configuration notecard into each door (Contents tab)
5. Impress your friends! Confound strangers!

Thanks again Newgate, really grateful
Biddily

CODE

//
/////////////////////////////////
//ultra basic sliding door script
//by Kyrah Abattoir
/////////////////////////////////

vector closed = <0,0,0>;//XYZ coordinates of the door when closed
vector open = <0,0,0>;//XYZ coordinates of the door when closed
float time = 3.0;//time before the door close itself
list allowedNames;
string notecard = "Configuration";
integer lineCounter;
key dataRequestID;
//
// helper functions
//

integer AllowEntry(key id)
{
string name = llToLower(llKey2Name(id));
integer iIndex = llListFindList(allowedNames, [ name ]);
// Always allow the owner
if(llGetOwner() == id) iIndex = 9999;

integer result = FALSE;
if(iIndex >= 0) result = TRUE;
return result;

}


Changed(integer change)
{
// Test for a changed inventory
if (change & CHANGED_INVENTORY)
{
llResetScript();
}
else if (change & CHANGED_OWNER)
{
llResetScript();
}
}
//--------------------------------------------------------------------------------
default
{
state_entry()
{
state ReadConfig;
}

on_rez (integer num) { llResetScript(); }

changed(integer change) { Changed(change) ; }
}
//--------------------------------------------------------------------------------
state Running
{
state_entry()
{
closed = llGetPos();
llSetPos(closed);
llSetText("",<1,1,1>,1.0);//REMOVE THIS LINE
}

touch_start(integer total_number)
{
key id = llDetectedKey(0);
if(AllowEntry(id))
{
llSetPos(open);
llSleep(time);
llSetPos(closed);
}
else
{
llWhisper(0,"Sorry but only allowed people can open this door");
}
}


changed(integer change) { Changed(change) ; }


}

//--------------------------------------------------------------------------------
state ReadConfig
{
state_entry()
{
lineCounter = 0;
allowedNames = []; // List of Allowed Users
integer itemtype = llGetInventoryType(notecard);
if(INVENTORY_NOTECARD == itemtype)
{
dataRequestID = llGetNotecardLine(notecard, lineCounter);
llSetTimerEvent(10);
}


}

dataserver( key query_id, string data ) // read from the notecard
{
if(query_id == dataRequestID)
{
if (data != EOF)
{
if(llGetSubString(data, 0,0) != ";")
{
allowedNames = (allowedNames = []) + allowedNames + [ llToLower(data) ];
llOwnerSay("Allowing "+data);
}
lineCounter++;
dataRequestID = llGetNotecardLine( notecard, lineCounter );
}
else
{
llSetTimerEvent(0);
state Running;
}
}
}

timer()
{
llOwnerSay("ERROR - Dataserver time out! aborting");
llSetTimerEvent(0);
state Running;
}

on_rez(integer num) { llResetScript(); }

changed(integer change) { Changed(change) ; }

}
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
oops
03-09-2007 04:51
Sorry , did it all from memory and screwed up.

Your corrections are fine, all teh error message did was warn you if you had forgotten the notecard and then should have taken you to state Running, not open.

One of draw backs of your approach is that you have to manually edit the script each time you move to door. A better way is to contain all of the configuration data in the notecard, not just the peoples names. It reqiures a little bit of rework to teh script but is worth teh effort if you use teh doors in lots of places.

A further 'enhancement' would be to have to door alwasys rez in teh closed position , and add code to reset the script if you reposition it. That way you need only store the open coordiantes as the door itself will read its closed coordianets when its rezzed/reset. Obviously doint this would require you use relative coordiantes not absolute ones!