Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help with permissions on a touch event

Artemis Cain
Take it or Leave it
Join date: 11 Apr 2005
Posts: 116
06-07-2006 08:59
I moved this out of the thread it was in because I fear it was causing too much confusion.
I was having a problem earlier with checking names for permission to give voice commands. (this part is now working)

the following code is for a problem I am having doing basically the same thing, only using a touch event instead of a listen.

The top bit of code is for the root prim. This code works fine and passes the list as a csv to the child prim with no problem.

I set up llSay commands on the child prim to verify that it was getting the data and placing it in to a list.

the problem I am having is that on the touch_start event, it will not recognize my authorized touchers as having permission to touch.




This is the code for ROOT_PRIM (compiles and runs fine)
CODE

string gName = "Names";
string owner;
list names_known = [];
list speaker = [];
integer gLine = 3;
key gQueryID;

default
{
on_rez(integer start_param)
{

owner = llKey2Name(llGetOwner());
gQueryID = llGetNotecardLine(gName, gLine); // request first line

}


dataserver(key query_id, string data) {
if (query_id == gQueryID) {
if (data != EOF)
{ // not at the end of the notecard
llSay(0,"Reading Line :" + (string)(gLine - 2)); // output the line
names_known = llListInsertList(names_known, llCSV2List(data), 0);// trying to return a CSV list of names the script knows
++gLine; // increase line count
gQueryID = llGetNotecardLine(gName, gLine); // request next line
}

if(data == EOF)
llMessageLinked(LINK_SET, 0, llList2CSV(names_known), "");
// this is actually passing the data fine... I have put some llSay commands in to test it
}

state_entry()
{

llListen(0,"",llGetOwner(),"Hi there!");
}

listen(integer chan, string name, key id, string message)
{
speaker = [llKey2Name(id)];
if( llListFindList( names_known, speaker) == -1)

{
llSay(0, "I shouldn't talk to strangers, "+llKey2Name(id)+ "." );
return; // this user is not on the list
}

llSay(0, "Greetings, "+llKey2Name(id)+ ". How have you been?");
}
}


In the code above, I have no problem at all with the data being passed.

when I get to the object, however....
I am having problems.

This is code for child prim(compiles fine, receives string from root, but doesn't compare for authorization):
CODE

string sitting ="";
string authorized = "";
list names_known= [];
list toucher = [];
default
{

touch_start( integer num )
{
toucher = [llKey2Name(llDetectedKey(0))];


if( (llListFindList(names_known, toucher)) == -1) //checks to see if the person touching is on the list
{
llInstantMessage(llDetectedKey(0), "I really shouldn't talk to strangers");
return;
}
}

link_message( integer sender, integer num, string message, key id )
{
if ( ( sender ==LINK_ROOT) && (message !="tex_req") && (id =="") )
{
authorized = message;
names_known += authorized;
//llSay(0, llList2CSV(names_known)); // test to see if names were passed
}
if( (sender == LINK_ROOT) && ( message ==""))
{
sitting = id;
names_known += sitting; // there is a seat that if sat on.. will allow the person
to interact.
//llSay(0, llList2CSV(names_known)); // test to see if names were passed
}

if ( (sender == LINK_ROOT) && (message =="remove") && (id =="remove") )
// this is if the person sitting stands up. (this all works)
{
names_known= []; //clears the list
//llSay(0, llList2CSV(names_known)); //verify list is cleared
names_known += authorized; // re add only the names from the list
//llSay(0, llList2CSV(names_known)); // verify re add
}
}
}



all of the code compiles fine and everything gets passed. (note: I just kinda wrote a mock up of exactly what I am doing in the real code, everything is verbatim as far as functions)


However, when anyone touches the object, they get the "I really shouldn't talk to strangers" message, including the names on the list and the owner

is there a totally different function to check validity for the touch event than there is for the listen event?

I am stumped on this one....
Bitzer Balderdash
Dazed and Confused
Join date: 21 Dec 2005
Posts: 246
06-07-2006 09:19
As far as I can see, you would have a notecard something like

Bob,Fred
Foo,Bar,Baz

read it and prduce a list such as
["Bob","Fred","Foo","Bar","Baz"]

which you pass to the child as a csv line

the child then adds this line to it's list - as a single element

so, the only way you will get a hit, is if a guy called "Bob","Fred","Foo","Bar","Baz" clicks on the button.

I could be wrong, but I don't see where you unpack it in the child script

Oh, and that will look correct if you print it using llList2CSV :)
try outputting the lenght of the list as well for debug.
Artemis Cain
Take it or Leave it
Join date: 11 Apr 2005
Posts: 116
06-07-2006 09:46
From: Bitzer Balderdash
As far as I can see, you would have a notecard something like

Bob,Fred
Foo,Bar,Baz

read it and prduce a list such as
["Bob","Fred","Foo","Bar","Baz"]

which you pass to the child as a csv line

the child then adds this line to it's list - as a single element

so, the only way you will get a hit, is if a guy called "Bob","Fred","Foo","Bar","Baz" clicks on the button.

I could be wrong, but I don't see where you unpack it in the child script

Oh, and that will look correct if you print it using llList2CSV :)
try outputting the lenght of the list as well for debug.

That worked!

I did an llCSV2List on the variable authorized

Good thing I'm not bad at scripting... or else nothing I do would ever work... ;)
Burke Prefect
Cafe Owner, Superhero
Join date: 29 Oct 2004
Posts: 2,785
06-07-2006 09:54
From: Artemis Cain
That worked!

I did an llCSV2List on the variable authorized

Good thing I'm not bad at scripting... or else nothing I do would ever work... ;)


Sweet. Now post the code so us schmucks can see a working result!
_____________________
Artemis Cain
Take it or Leave it
Join date: 11 Apr 2005
Posts: 116
06-08-2006 06:41
From: Burke Prefect
Sweet. Now post the code so us schmucks can see a working result!


As soon as I clean up my latest can of worms that fixing that part has led to...
permissions drive me batty