|
Billy Islander
Registered User
Join date: 3 Nov 2006
Posts: 35
|
07-13-2007 17:39
i have a sliding door script which i got from the forums which is supposed to be locked to all except people on the notecard access list but it seems anyone can open and close the door , the script is as follows , can anyone please help me
PHP integer gSteps = 5; vector gOpenOffset = <0.5,0.0,0.0>; vector gClosedOffset = <-0.5,0.0,0.0>; list allowedNames; string notecard = "allowed users"; 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 Closed; } }
state Closed {
touch_start(integer total_number) {
integer i; vector basepos = llGetPos();
for (i=0; i <= gSteps; i++) { llSetPos(basepos + i*gOpenOffset); //llSleep(0.05); }
state open; } }
state open { touch_start(integer num) { integer i; vector basepos = llGetPos();
for (i=0; i <= gSteps; i++) { llSetPos(basepos + i*gClosedOffset); // llSleep(0.1); }
state Closed; } } PHP
|
|
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
|
07-13-2007 17:53
That script is all screwed up. Throw it away and search for another.
For one, changed is an event which should be within a state (such as the default state). And nowhere in that script is a notecard read. Also, nowhere in that script is the function "AllowEntry" called. The function is defined under "helper function" but if you examine the rest of the script, you see it is never used.
Basically, all the script does is wait for a touch while closed, then animates open and waits for another touch to go back to the closed state.
|
|
Billy Islander
Registered User
Join date: 3 Nov 2006
Posts: 35
|
07-13-2007 19:03
From: DoteDote Edison That script is all screwed up. Throw it away and search for another.
For one, changed is an event which should be within a state (such as the default state). And nowhere in that script is a notecard read. Also, nowhere in that script is the function "AllowEntry" called. The function is defined under "helper function" but if you examine the rest of the script, you see it is never used.
Basically, all the script does is wait for a touch while closed, then animates open and waits for another touch to go back to the closed state. thanks for the info DoteDote ,i,m not a scriptor so ca,nt fix this 1 myself , i tried looking for another script but cant find 1 with touch control and notecard access , guess i,ll have to look on sl exchange for something.
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
07-14-2007 10:09
From: DoteDote Edison That script is all screwed up. Throw it away and search for another.
For one, changed is an event which should be within a state (such as the default state). And nowhere in that script is a notecard read. Also, nowhere in that script is the function "AllowEntry" called. The function is defined under "helper function" but if you examine the rest of the script, you see it is never used.
Basically, all the script does is wait for a touch while closed, then animates open and waits for another touch to go back to the closed state. I agree this is a chopped up version of something I posted a few months back. changed is an event, Changed is a user defined function written to be used in all changed event handlers across multiple states rather than repeat the same code. The AllowEntry function should be being called within the touch handlers state Closed {
touch_start(integer total_number) { key id = llDetectedKey(0); if(AllowEntry(id) { integer i; vector basepos = llGetPos();
for (i=0; i <= gSteps; i++) { llSetPos(basepos + i*gOpenOffset); //llSleep(0.05); } state open; } }
changed(integer change) { Changed(change); } }
_____________________
I'm back......
|
|
Billy Islander
Registered User
Join date: 3 Nov 2006
Posts: 35
|
07-15-2007 02:16
From: Newgate Ludd I agree this is a chopped up version of something I posted a few months back. changed is an event, Changed is a user defined function written to be used in all changed event handlers across multiple states rather than repeat the same code. The AllowEntry function should be being called within the touch handlers state Closed {
touch_start(integer total_number) { key id = llDetectedKey(0); if(AllowEntry(id) { integer i; vector basepos = llGetPos();
for (i=0; i <= gSteps; i++) { llSetPos(basepos + i*gOpenOffset); //llSleep(0.05); } state open; } }
changed(integer change) { Changed(change); } }
Thankyou Newgate , after looking in my inventory i found that this script was in a "box" of scripts i picked up somewhere anyway thankyou for replying , i shall attempt to insert the other part of of your script into what i have , i,m trying to learn scripting ,spending a lot of time at the Bromley College exhibition.I would appreciate if you or anyone could point me in the direction of scripting classes , have looked in events but to no avail.
|