Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

A script to keep track of who touches an object?

Nepenthes Ixchel
Broadly Offended.
Join date: 6 Dec 2005
Posts: 696
12-17-2005 00:44
How can I create a script to keep track of who touches an object? Is it possible to store names in a variable and then repeat them back on some trigger? And if so, what happens to the stored variable if the object is moved to inventory or the sim restarts; is the data saved?
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
12-17-2005 00:56
CODE

list touchedBy;

default
{

state_entry()
{
touchedBy = [];
}

touch_start(integer n)
{
if (llDetectedKey(0) == llGetOwner()) {
integer f;
integer touchedCount = llGetListLength(touchedBy);
for (f=0; f<touchedCount; f++) llOwnerSay(llList2String(touchedBy, f));
} else {
string name = llDetectedName(0);
if (llListFindList(touchedBy, [name]) == -1) touchedBy += name;
}

}

}

would be some basic code. That records everyone's names in a list, checks to see if they've touched before to avoid double-counting, and if the owner touches it, instead of recording that touch it reads out all the names.

What you have to worry about is if lots of different people touch the object and it runs out of memory to store the names. If you're expecting hundreds, you might want to have it instant message or email you with the names once the list reaches a certain size, and then wipe the list. Of course, wiping the list would mean that you could get duplicate names on different lists... apart from putting the names on a notecard and using dataserver to check that each time, I'm not sure what the way round that would be.
Nepenthes Ixchel
Broadly Offended.
Join date: 6 Dec 2005
Posts: 696
12-17-2005 02:23
Thanks, I'm not expecting hundreds. I'm just curous who is playing with the toys I left on my workshop floor. (given that the "workshop" is just a wood platform I occasionly get drop by visitors looking)