Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Making a list of people on touch.

Velvet Axon
Registered User
Join date: 3 Nov 2005
Posts: 3
11-14-2005 09:31
Hey there. I need to figure out how to make a script for an object that does this: When an AV right clicks and "touches" the object, their name is recorded and placed in a list. Thankies.
FireEyes Fauna
Registered User
Join date: 26 Apr 2004
Posts: 138
11-14-2005 09:35
CODE

list lNAMES;

default
{
touch_start(integer num)
{
lNAMES += [llDetectedName(0)];
}
}
JP Burleigh
Registered User
Join date: 15 Oct 2005
Posts: 11
11-14-2005 09:39
Try storing their information in a list. You can use a strided list if you want to store multiple pieces of info such as name, time of touch, etc.
You can then add a command to IM or Email you back the list depending on your goals.

Be careful not to let the list get too big. You get 16kb to store the script and the data. The object will crash if you exceed that allocation. Therefore you will want to email off the data and reset the list after x touches (x be ing dependent on how much data you are storing).

Hope that helps
Gaz Hornpipe
Registered User
Join date: 29 Sep 2005
Posts: 36
11-14-2005 10:54
CODE
list gNames;
integer channel = -7272;
integer listening;

default
{
touch_start(integer num)
{
// If the owner touches, display dialog to show or clear the list
if(llDetectedKey(0) == llGetOwner())
{
llDialog(llDetectedKey(0),"Name List Menu\n\nShow - Show the current list.\nClear - Clear the current list.",["Show","Clear"],channel);
listening = llListen(channel,"",llDetectedKey(0),"");
return;
}

// Only add people who are not currently on the list
if(llListFindList(gNames,[llDetectedName(0)]) == -1)
gNames += llDetectedName(0);
}

listen(integer channel, string name, key id, string message)
{
llListenRemove(listening);
if(message == "Clear")
{
gNames = [];
llWhisper(0, "The list of names has been cleared.");
return;
}

if(message == "Show")
{
integer len = llGetListLength(gNames);
if(len > 0)
{
integer i;
for(i = 0; i < len; ++i)
llWhisper(0, llList2String(gNames,i)
llWhisper(0, "There were " + (string)len + " names on the list.");
llWhisper(0, "There are " + (string)llGetFreeMemory() + " bytes free.");
return;
}
else
{
llWhisper(0, "No names are on the list.");
llWhisper(0, "There are " + (string)llGetFreeMemory() + " bytes free.");
return;
}
}
}
}
Velvet Axon
Registered User
Join date: 3 Nov 2005
Posts: 3
syntax error
11-14-2005 21:21
Hey. This code keeps sending a syntax error at 39 16. What do I need to do to fix it????
Ben Bacon
Registered User
Join date: 14 Jul 2005
Posts: 809
11-15-2005 03:31
From: Velvet Axon
Hey. This code keeps sending a syntax error at 39 16. What do I need to do to fix it????
common coding typo - add a semi-colon at the end of line 39
CODE

. . .
. . .
for(i = 0; i < len; ++i)
llWhisper(0, llList2String(gNames,i); // <-- add ";" here
llWhisper(0, "There were " + (string)len + " names on the list.");
. . .
. . .
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
11-15-2005 04:57
I'm curious since I am going to do something similar, but when I delete part of a list, does it update the index values for the items?

e.g:

0 - Haravikk Mistral
1 - Bob Turner
2 - Some Person

If I remove Bob Turner, does Some Person's number change to 1?
It just seems that it may be better in cases to have a limit on how big your list will get, if it has reached this, then you delete the first (oldest) entry in the list and add the next one.
I know that doing this involves copying of lists, but if your limit is relatively good (e.g 15 names) then it shouldn't be too inefficient. Or even have niceties like checking to see if a user is already in the list, removing them from it and placing them at the end (ie to update their position).
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
11-15-2005 05:08
Yes, if you delete an element of a list the entire list is reindexed.

Topping and tailing like that I've not tried, but agree it shouldn't be too inefficient - although I'm inclined to ask why you're doing it - options such as IMing or emailing the list might be more appropriate.
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
11-15-2005 08:39
NDE--Nilsson Development Enterprises has a script that adds/deletes people from a list on touch and is able to automatically distribute any object to people on the list quickly and easily.
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.