Door Access List help
|
|
Billy Islander
Registered User
Join date: 3 Nov 2006
Posts: 35
|
09-04-2008 07:48
I am trying to make a door with notecard access that always works for the owner based on the Void Singer door script i found at /54/a7/232450/1.htmlThis is an amazing door that can be moved and rotated without affecting the door rotation.The problem is Voids example has to have the owner added to the notecard , i,ve messed about with it and got it to work for the owner but when i add other names to the card it says "Allowing "name added" but the other av still can,t work the door , any help would be greatly appreciated.php is as follows.
//--// v7-D Feebie Type 1 Door Script //--// //--// Works At ANY Angle //--//
//-- works in ANY single prim door, linked or un-linked //-- works in muti prim doors NOT linked to a larger structure //-- REQUIREMENTS: a cut root prim, suggest cube, pathcut start=.125, end=.625 //-- CAVEAT: single prim doors are limited to 5m width
//--// USERS MODIFY HERE v integer vgIntDoorSwing = -70; rotation vgRotDoorSwing; /////////////////////
list allowedNames; string notecard = "whitelist"; 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() { vgRotDoorSwing = llEuler2Rot( <.0, .0, (float)vgIntDoorSwing * DEG_TO_RAD> );
}
touch_start(integer total_number) { key id = llDetectedKey(0); if(AllowEntry(id)) { //- small hack to reverse direction of swing on each //- touch & avoid lsl funkiness regarding rotation division vgRotDoorSwing.s *= -1;
//-- like sounds? add one here! llSetLocalRot( vgRotDoorSwing * llGetLocalRot() ); } 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) ; }
}
|
|
Yingzi Xue
Registered User
Join date: 11 Jun 2008
Posts: 144
|
09-04-2008 08:07
Here's your problem:
allowedNames = (allowedNames = []) + allowedNames + [ llToLower(data) ];
What the above line is doing is emptying the allowedNames list every time it adds a user to the list. Thus, only one user is ever in the list--the last user read from the notecard. You only need to empty the list at the beginning of the script. Here's your fix...
Place this in your state_entry:
allowedNames = [];
Replace this line...
allowedNames = (allowedNames = []) + allowedNames + [ llToLower(data) ];
...with this...
allowedNames += llToLower(data);
User names should now add to the list when the notecard is read.
|
|
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
|
Small mistake:
09-04-2008 08:19
From: Yingzi Xue
allowedNames += llToLower(data);
This should be: allowedNames += [llToLower(data)];
|
|
Billy Islander
Registered User
Join date: 3 Nov 2006
Posts: 35
|
09-04-2008 08:24
From: Yingzi Xue Here's your problem:
allowedNames = (allowedNames = []) + allowedNames + [ llToLower(data) ];
What the above line is doing is emptying the allowedNames list every time it adds a user to the list. Thus, only one user is ever in the list--the last user read from the notecard. You only need to empty the list at the beginning of the script. Here's your fix...
Place this in your state_entry:
allowedNames = [];
Replace this line...
allowedNames = (allowedNames = []) + allowedNames + [ llToLower(data) ];
...with this...
allowedNames += llToLower(data);
User names should now add to the list when the notecard is read. Wow Yingzi that was a fast reply and it worked perfectly thankyou so much.Hopefully this will be usefull to other people , the door can be moved and rotated without affecting it , also it updates itself when the notecard is saved after adding names.Ideal for reselling of buildings with doors.Many thanks to Void Singer for the original and yourself for the help Yingzi.Fixed script as follows.
//--// v7-D Feebie Type 1 Door Script //--// //--// Works At ANY Angle //--//
//-- works in ANY single prim door, linked or un-linked //-- works in muti prim doors NOT linked to a larger structure //-- REQUIREMENTS: a cut root prim, suggest cube, pathcut start=.125, end=.625 //-- CAVEAT: single prim doors are limited to 5m width
//--// USERS MODIFY HERE v integer vgIntDoorSwing = -70; rotation vgRotDoorSwing; /////////////////////
list allowedNames; string notecard = "whitelist"; 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() { vgRotDoorSwing = llEuler2Rot( <.0, .0, (float)vgIntDoorSwing * DEG_TO_RAD> );
}
touch_start(integer total_number) { key id = llDetectedKey(0); if(AllowEntry(id)) { //- small hack to reverse direction of swing on each //- touch & avoid lsl funkiness regarding rotation division vgRotDoorSwing.s *= -1;
//-- like sounds? add one here! llSetLocalRot( vgRotDoorSwing * llGetLocalRot() ); } 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 += 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) ; }
}
|
|
Billy Islander
Registered User
Join date: 3 Nov 2006
Posts: 35
|
09-04-2008 08:29
From: Ron Khondji This should be:
allowedNames += [llToLower(data)]; Many thanks Ron , i was just replying to Yingzi when you posted , as you pointed out just a small error in code but every mistake helps the learning curve.
|
|
Very Keynes
LSL is a Virus
Join date: 6 May 2006
Posts: 484
|
09-04-2008 08:30
From: Yingzi Xue Here's your problem:
allowedNames = (allowedNames = []) + allowedNames + [ llToLower(data) ];
What the above line is doing is emptying the allowedNames list every time it adds a user to the list. Although what you say is LOGICALLY correct, in the LSL context it is incorrect. without going into too much technical detail, this is a trick that relies on LSL order of execution to conserve memory in the shared 16K memory block allocated at runtime. It is a trick I use often and it works equity well on strings, I am not sure if it still provides any memory saving benefit when compiled for MONO but it is still supported and therefore shouldn't be what is coursing the script to fail. I will wait for Void to add her own input 
|
|
Billy Islander
Registered User
Join date: 3 Nov 2006
Posts: 35
|
09-04-2008 08:41
From: Very Keynes Although what you say is LOGICALLY correct, in the LSL context it is incorrect. without going into too much technical detail, this is a trick that relies on LSL order of execution to conserve memory in the shared 16K memory block allocated at runtime. It is a trick I use often and it works equity well on strings, I am not sure if it still provides any memory saving benefit when compiled for MONO but it is still supported and therefore shouldn't be what is coursing the script to fail. I will wait for Void to add her own input  Just a quick note Very , the access list part of the script is,nt part of Voids original , i cobbled it together from various scripts posted on the forum because Voids original had to have the owner on the notecard to work i only used Voids rotation script which works amazingly well in buildings that are rezzed and then moved or rotated.
|
|
Yingzi Xue
Registered User
Join date: 11 Jun 2008
Posts: 144
|
09-04-2008 15:57
From: Ron Khondji This should be:
allowedNames += [llToLower(data)]; Question: What's the rule on this? I've always been able to add to a list without using the list brackets (using mylist += mydata; ). Are the brackets required for LSL functions?
|
|
Billy Islander
Registered User
Join date: 3 Nov 2006
Posts: 35
|
09-05-2008 04:52
From: Yingzi Xue Question:
What's the rule on this? I've always been able to add to a list without using the list brackets (using mylist += mydata; ). Are the brackets required for LSL functions? The script works perfectly well without the brackets Yingzi , i tried it inworld.
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
09-05-2008 23:36
just a side note, the original notecard read version that billy was playing with (not posted) may be one I had a quick request for, which was for a rental style property, so all users that had access had to be listed (or perhaps it was just a mod of the original. as noted the format: list = (list=[]) + list + [data]; is to conserve list memory from doubling during adds (good for big lists) the brackets serve as a way to typecast the data to list, saving possible confusion in the compiler of the datatype... although for single items the format: (list)data; is slightly faster and tighter codewise (knowledge thanks to testing by strife) after a quick look you need to change a single line allowedNames = []; // List of Allowed Users in the readConfig state.... to: allowedNames = (list)llToLower(llGetOwner()); //-- always authorize owner and the allowEntry function can more quickly be rewritten as integer AllowEntry( key id ){ return ~llListFindList( allowedNames, (list)llToLower( llKey2Name( id ) ) ); }
That will force the owner into the list when it's built in the read section, then use a universal test to see if the owner (or other person) is there.... you could have also shortcutted it at the touch event by testing the id vs the owner key (which avoids problems of transfer without having to wait for the notecard to build the list) but it adds an extra test that you may not want in a high traffic area NOTE: find_something = false if its the first item, true if it's ANYTHING else ~find_something = true if found, false if not (turns -1 to 0 or false which is whaat you get on not found, all else will come up a number including the first index of zero) PS sorry to billy for not being able to come by here sooner... net access is touchy atm... <1mo till a return to normal... I hope
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|