Notecard Access List - I made a mess :-(
|
|
Dmitriy Gausman
Registered User
Join date: 16 May 2007
Posts: 132
|
08-24-2008 18:44
I successfully made a slide presentation board I will be using to teach with from the script below. It advances and reverses the photos by both chat and touch commands. I was able to set security embedded in the script so only those authorized could use it. My preference was to use a notecard for the access list. As you can see, I am not good at that part and I made a mess of what had been for a few hours, a nicely running script. I still have not gotten the feel for where things can and cannot go. Any help would be very much appreciated. Dmitriy // TWO-BUTTON TEXTURE VENDOR // Origional script by Thili Playfair // Heavily Modified by Karandas Banjo // Tiny alter by Maxwell Harmison (just so I can put my name in it...lol) // Further edited and anhialated by Dmitriy Gausman // Please include these names if you modify or // re-distribute this code ^_^
// ACCESS LIST NOTECARD VARIABLES: //list auth = ["", ""];//Used only if no notecard will be used string cardname="access list dg"; //notecard name for board access integer gLine = 0; //current notecard line number key gQueryID; //id used to identify dataserver queries string avname; //name of person touching board to cross check with
float time = 0; // Enter a value if you want time based // scrolling otherwise set to zero.
string vendorname; integer total; integer counter; integer change;
next() { total=llGetInventoryNumber(INVENTORY_TEXTURE); vendorname = llGetObjectName(); counter++; if(counter>=total) { counter=0; } llSetTexture(llGetInventoryName(INVENTORY_TEXTURE,counter),4); } prev() { total=llGetInventoryNumber(INVENTORY_TEXTURE); vendorname = llGetObjectName(); if (counter > 0) { counter--; } else { counter=total - 1; } llSetTexture(llGetInventoryName(INVENTORY_TEXTURE,counter),4);
}
default { state_entry() { next(); llListen(9,"","",""); llSetTimerEvent(time); } listen(integer channel, string name, key id, string msg) { if (msg == "next") { next(); } else if (msg == "prev") { prev(); } else if (msg == "erase") { llSetTexture("chalkboard_plain",4); counter=0; } }
// this is where it really unravels. I just want to check the notecard to see of the person who touched the board is authorized to use the buttons. It would be nice to also deny them chat command access as well
touch_start(integer total_number) { gQueryID = llGetNotecardLine(cardname, gLine); // request first line avname=llDetectedName(0); //sets the name of the avatar that touched chalkboard }
dataserver(key query_id, string data) { if (query_id == gQueryID) { if (data != EOF) { // not at the end of the notecard if (data == avname) { llSay(0,"Hello, You have access"); allow = 1; } //llSay(0, (string)gLine+": "+data); // output the line ++gLine; // increase line count gQueryID = llGetNotecardLine(cardname, gLine); // request next line } } allow() //if( llListFindList( auth, (list)llDetectedName(0) ) != -1 ) { if ( llGetLinkName(llDetectedLinkNumber(0)) == "next" ) { next(); } else if ( llGetLinkName(llDetectedLinkNumber(0)) == "prev" ) { prev(); } else if ( llGetLinkName(llDetectedLinkNumber(0)) == "erase" ) { llSetTexture("chalkboard_plain",4); counter=0; } else llSay(0,"Sorry, You are not authorized to access this board"); } } timer() { next(); }
on_rez(integer start_param) { llResetScript(); } }
|
|
revochen Mayne
...says
Join date: 14 Nov 2006
Posts: 198
|
08-24-2008 19:09
Hi Dmitriy  There is really a bit of weirdness. First i've noticed a few llDetected* functions that are restricted to touch+collission events only! So no sense at all to use them in a dataserver event. The second thing is that you always want to read the notecard (geting admit names) when someone touchs the object, that is not common practice. You better should first read the notecard via your script and store the names into a global list. Then you can pretty easy check in the touch_start event if the agents name is one of the admit names in the list. My last tip is (ab)using the objects description field to put names in that are allowd to use the object. Thats what i do with with objects that needs an admit list by just putting names in the desc field seperated by commas. =) default { touch_start(integer total_number) { if( llListFindList( llCSV2List(llGetObjectDesc()) ,(list)llDetectedName(0) ) != -1) { llSay(0, "you are allowed to use me!"); } else { llSay(0,"sorry, access denied!"); } } }
|
|
Dmitriy Gausman
Registered User
Join date: 16 May 2007
Posts: 132
|
08-25-2008 07:30
Hi,
Thank you very much for replying to me. I am still very lost though. Making the list of access names into a global variable would be nice. I am not sure if I would want the names in the description, as I think anyone would be able to see the names, even if they could not change them. Another thing I don't understand in the LSL scripting yet is how to exit a loop and go on (I will dig for that today). So for example, I am sure the card is being read, and I know that it is finding a match from the detected avatar to the list, but if the access list has 8 people and the 3rd on the list has permissions, I don't know how to stop searching and move past the "if" condition it was testing.
Dmitriy
|
|
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
|
08-25-2008 08:31
From: revochen Mayne Hi Dmitriy  There is really a bit of weirdness. First i've noticed a few llDetected* functions that are restricted to touch+collission events only! So no sense at all to use them in a dataserver event. That is not weirdness, it's documented behavior. llDetected* functions work *only* from event handlers that have a "integer total_number" parameter, such as touch, collision, and sensor events. Using them in other handlers will not do anything useful.
|
|
revochen Mayne
...says
Join date: 14 Nov 2006
Posts: 198
|
08-25-2008 08:44
Hi again  There is no need for a loop to check if the avatars name is in the admit list. You just have to store each line (admit name) from the notecard into a list element. Then you can use llListFindList that will return a -1 if name is not found in the list or a higher value (the index number of the element in the list, starting with 0). @Lear Thx for the revision. ^^
|
|
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
|
Try this one.
08-25-2008 09:19
// TWO-BUTTON TEXTURE VENDOR // Origional script by Thili Playfair // Heavily Modified by Karandas Banjo // Tiny alter by Maxwell Harmison (just so I can put my name in it...lol) // Further edited and anhialated by Dmitriy Gausman // Please include these names if you modify or // re-distribute this code ^_^
// ACCESS LIST NOTECARD VARIABLES: //list auth = ["", ""];//Used only if no notecard will be used string cardname; //notecard name for board access integer gLine = 0; //current notecard line number key gQueryID; //id used to identify dataserver queries string avname; //name of person touching board to cross check with
float time = 0; // Enter a value if you want time based // scrolling otherwise set to zero.
string vendorname; integer total; integer counter; integer change; integer allow;
check_allow() { gQueryID = llGetNotecardLine(cardname, gLine); // request first line }
next() { counter++; if(counter>=total) counter=0; llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, counter),4); }
prev() { if (counter > 0) counter--; else counter=total - 1; llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, counter),4); }
default { state_entry() { vendorname = llGetObjectName(); total=llGetInventoryNumber(INVENTORY_TEXTURE); cardname = llGetInventoryName(INVENTORY_NOTECARD,0); allow = 0; //next(); llListen(9,"","",""); llSetTimerEvent(time); }
listen(integer channel, string name, key id, string msg) { if (name != avname) allow = 0; if (allow){ if (msg == "next") next(); else if (msg == "prev") prev(); else if (msg == "erase"){ llSetTexture(TEXTURE_DEFAULT,4); counter=0; } } else{ avname = name; check_allow(); } }
// this is where it really unravels. I just want to check the notecard to see of the person who touched the board is authorized to use the buttons. It would be nice to also deny them chat command access as well
touch_start(integer total_number) { string name = llDetectedName(0); //sets the name of the avatar that touched chalkboard if (name != avname) allow = 0; if (allow){ if ( llGetLinkName(llDetectedLinkNumber(0)) == "next" ) next(); else if ( llGetLinkName(llDetectedLinkNumber(0)) == "prev" ) prev(); else if ( llGetLinkName(llDetectedLinkNumber(0)) == "erase" ){ llSetTexture(TEXTURE_DEFAULT,4); counter=0; } } else{ avname = name; check_allow(); } }
dataserver(key query_id, string data) { if (query_id == gQueryID){ if (data != EOF){ // not at the end of the notecard //llSay(0, (string)gLine+": "+data); // output the line if (data == avname){ allow = 1; llSay(0,"Hello, " + avname + ". You have access"); } else{ ++gLine; // increase line count gQueryID = llGetNotecardLine(cardname, gLine); // request next line } } else llSay(0,"Sorry, You are not authorized to access this board"); } }
timer() { next(); }
on_rez(integer start_param) { llResetScript(); } }
|
|
Dmitriy Gausman
Registered User
Join date: 16 May 2007
Posts: 132
|
08-25-2008 09:46
Thank you Revochen, Lear, and Ron. I used the edited code that Ron passed on and it worked perfectly. I am so appreciative of that help Ron.
It helps to see how I can learn more about the LSL coding requirements. I have programmed in rl a medical billing program that is used in several physician's offices, but sadly, I am feeling dense with the LSL language as far as where and how certain codes react (within events), and once I lose that path, my whole logic gets confused.
So thank you again for your help.
Dmitriy
|
|
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
|
08-25-2008 10:54
FYI, I finally got around to posting code to read config notecards. It's a bit more robust than the versions posted elsewhere, and may be more than you need, but if you're interested you can check it out here: https://wiki.secondlife.com/wiki/AdvancedNotecardReader
|
|
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
|
08-25-2008 10:57
From: Dmitriy Gausman Thank you Revochen, Lear, and Ron. I used the edited code that Ron passed on and it worked perfectly. I am so appreciative of that help Ron.
It helps to see how I can learn more about the LSL coding requirements. I have programmed in rl a medical billing program that is used in several physician's offices, but sadly, I am feeling dense with the LSL language as far as where and how certain codes react (within events), and once I lose that path, my whole logic gets confused.
So thank you again for your help.
Dmitriy Event-driven programming takes a bit of time to get used to, but it's the right model for this kind of scripting, and LSL makes it considerably easier and understandable than any event-driven coding model I've used in 30 years of writing professional event-driven code for communications, data acquisition, and real-time control.
|