Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Need some help with a visitor list maker

Myhrrhleine Wingtips
Registered User
Join date: 10 Mar 2008
Posts: 29
07-10-2008 08:09
Hello, Im Baaaack lol

Ok Im in the very early stages of a security system project that requires a list of the 12 most recent visitors to a location. So I created a collision based visitor list maker no problem there. However I need this visitor list to store both the visitors name and Key. I need the name to be able to display in an llDialog a little later, and I need the key to be able to pass to the land functions.

What I have seems to be working correctly so far except for some reason my list containing the keys is always returning an empty value. What am I doing wrong? Any assistance to make it more efficient would also be helpful.

CODE


list visitor_list;
list key_list;


integer isNameOnList( string name )
{
integer len = llGetListLength( visitor_list );
integer i;
for( i = 0; i < len; i++ )
{
if( llList2String(visitor_list, i) == name )
{
return TRUE;
}
}
return FALSE;
}


default
{
state_entry()
{

llVolumeDetect(TRUE);
}

collision_start( integer number_detected )
{
integer i;
for( i = 0; i < number_detected; i++ )
{
if( llDetectedType( i ) & AGENT )
{
//if( llDetectedKey( i ) != llGetOwner() ) //commented out for testing
// { //commented out for testing

string detected_name = llDetectedName( i );
string detected_key = llDetectedKey(i);

llOwnerSay(detected_name + " added");//Debug
llOwnerSay(detected_key + " added");//debug


if( isNameOnList( detected_name ) == FALSE )
{

visitor_list = llList2List( visitor_list + detected_name, -12, -1 );


key_list = llList2List( key_list + detected_key, -12, -1 );



}
// } //commented out for testing

}
}
}

touch_start(integer total_number) //For testing purposes
{
integer i;
integer length = llGetListLength(visitor_list);
string visitor;
string visitor_key;




for( i = 0; i < length; i++)

visitor = llList2String(visitor_list,i);
visitor_key = llList2String(key_list,i);

llOwnerSay(visitor + " = " + visitor_key );
}

}
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
07-10-2008 09:57
change this:
key_list = llList2List( key_list + detected_key, -12, -1 );
to this
key_list = llList2List( key_list + [detected_key], -12, -1 );
it might do the trick:)
or this: (since detected_key is declared a string)
key_list = llList2List( key_list + [(key)detected_key], -12, -1 );
_____________________
From Studio Dora
Myhrrhleine Wingtips
Registered User
Join date: 10 Mar 2008
Posts: 29
07-10-2008 10:25
THanks for the help, but neither of those worked.
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
07-10-2008 10:48
Try putting a statement like this in your 'collision_start' handler to make sure you're getting there:

llOwnerSay("DEBUG - defaut/collision_start, point A";);

If you get there, put one somewhere else, like in the conditionals where you add an entry. You might even want to spit out a copy of one or both of your lists at the point where you add to them:

llOwnerSay("DEBUG - default/collision_start, point B; visitor added; visitor_list = "+llList2CSV(visitor_list));

That should help you start to track down the issue. Welcome to the world of printf type debugging. :-)