Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Using list and if with a Greeter?

Pablomex Commons
Registered User
Join date: 19 Apr 2006
Posts: 4
06-21-2007 12:13
Hello, I´m trying to build a greeter for an edu center in a mexican sim. This is the code that I´m using right now:

default
{
state_entry()
{
llVolumeDetect(TRUE);
}
collision_start(integer num_detected)
{
llSay(0, llDetectedName(0) + ",bienvenid@ a Wiener Lacus";);
llSleep(3);
}
}

BUT still with llSleep, the object repeats the names after the established sleep time. I will like to use "list" and "if", so the object does not greet an avatar more than once (and maybe even say goodbye when he goes out?). This is the code, I know it´s silly, but I get several errors while running it (either syntax or mismatch/scope), I´m not a scripter at all:S, this is just intuiton (pretty bad one) and code mixing jeje. I´ll appreciate some help:

list names;

default
{
state_entry()
{
llVolumeDetect(TRUE);
}
collision_start(integer num_detected)
{
integer x;
for (x = 0; x < 0; x++)
{
string name = llDetectedName(x);
integer index = llListFindList(names, (name));
if (index == 1)
{
llSay(0, llDetectedName(x) + ", bienvenid@ a Wiener Lacus";);

if (llGetListLength(names) > 20)
{
llDeleteSubList(names, 0, 0);
}
}
}
}
}
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
06-21-2007 16:29
You probably mean:
for (x = 0; x < num_detected; x++)
(not "x < 0";), although in fact, for a collision event, you can just lose the for loop and only worry about llDetectedName(0).

llListFindList wants lists as arguments, so you'll want:
integer index = llListFindList(names, [name]);
(not ";(name)";), and the function returns -1 when it doesn't find the target, so
if (index == -1)
(not "1";).

When you don't find the name on the list, in addition to greeting "name", you want to add it to the list for future comparison, with:
names += name;
and the logic to prune the list back to 20 elements.
Pablomex Commons
Registered User
Join date: 19 Apr 2006
Posts: 4
Thanks!
06-21-2007 17:58
Cheers Qie, I´ll try it out...Thanks.