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.
//
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 :
//
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
//
/////////////////////////////////
//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) ; }
}