START
string welcome;
// Global variables
list visitor_list;
float range = 3.0; // in meters
float rate = 1.0; // in seconds
// Functions
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;
}
init()
{
welcome = llGetObjectDesc();
llOwnerSay( "Visitor List Maker started..."
;llOwnerSay( "The owner can say 'help' for instructions."
; llSensorRepeat( "", "", AGENT, range, TWO_PI, rate );
llListen(0, "", llGetOwner(), ""
;}
// States
default
{
state_entry()
{
init();
}
on_rez( integer param )
{
init();
}
touch_start( integer num )
{
welcome = llGetObjectDesc();
}
sensor( integer number_detected )
{
integer i;
for( i = 0; i < number_detected; i++ )
{
if( llDetectedKey( i ) != llGetOwner() )
{
string detected_name = llDetectedName( i );
if( isNameOnList( detected_name ) == FALSE )
{
llInstantMessage( llDetectedKey( i ), welcome + detected_name);
visitor_list += detected_name;
llInstantMessage(llGetOwner(), "Tashi's Toys landing at " + llGetRegionName() + " has just detected " + llKey2Name(llDetectedKey(0)) + "!"
;llGiveInventory(llDetectedKey(0), "Tashi's Toys"
;}
}
}
}
listen( integer channel, string name, key id, string message )
{
if( id != llGetOwner() )
{
return;
}
if( message == "help" )
{
llOwnerSay( "This object records the names of everyone who" );
llOwnerSay( "comes within "+ (string)range + " meters." );
llOwnerSay( "Commands the owner can say:" );
llOwnerSay( "'help' - Shows these instructions." );
llOwnerSay( "'say list' - Says the names of all visitors on the list."
;llOwnerSay( "'reset list' - Removes all the names from the list." );
llOwnerSay ( "TO change the greeting - change the object description and touch the object" );
}
else
if( message == "say list" )
{
llOwnerSay( "Visitor List:" );
integer len = llGetListLength( visitor_list );
integer i;
for( i = 0; i < len; i++ )
{
llOwnerSay( llList2String(visitor_list, i) );
}
llOwnerSay( "Total = " + (string)len );
}
else
if( message == "reset list" )
{
visitor_list = llDeleteSubList(visitor_list, 0, llGetListLength(visitor_list));
llOwnerSay( "Done resetting."
;}
}
}
END
