Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

record number of touches

Herbert Toll
Registered User
Join date: 18 Dec 2006
Posts: 28
01-14-2007 06:03
hi guys, looked around the forums for a script with no joy.

i need a script that can record how many clicks an object gets and send the stats to my email maybe. Is this possible?
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-14-2007 06:44
From: Herbert Toll
hi guys, looked around the forums for a script with no joy.

i need a script that can record how many clicks an object gets and send the stats to my email maybe. Is this possible?


Yes, very easily.
You dont specify a time period over which to record the number of touches?

Basically you just need to increment a counter in the touch event and then when the timer expires email the data to the specified address.

NOTE emailing will delay the script for 20 seconds.

CODE

string emailAddress = "";
integer Counter = 0;
integer TimerInterval = 86400; // 1 day
default
{
state_entry()
{
Counter = 0;
llSetTimerEvent(TimeInterval);
}

touch_start(integer total_number)
{
++Counter;
}

timer()
{
// You can store some useful Information in the Description
llEmail(emailAddress , llGetObjectDesc() , " Was Touched " + (string)Counter + "Times in the recorded period.");
Counter = 0;
}
}
Herbert Toll
Registered User
Join date: 18 Dec 2006
Posts: 28
01-14-2007 08:14
thnx for that newgate very helpful.

could this script be modified to say, record touches on an object over and week and display them hovering above the object?

i dont know how hard that would be.

i am starting to learn scripting but havent got my head around it yet
Maximilan DeSantis
.:.:Scripting:.:.
Join date: 13 Jan 2007
Posts: 5
01-14-2007 08:35
You can display a Text above an Object with llSetText(string text, vector color, float alpha)

So a modified script could look like that:
CODE

integer Counter = 0;
integer TimerInterval = 86400; // 1 day (in seconds)
default
{
state_entry()
{
Counter = 0;
llSetText("Not Touched",<1.0,0,0>,1.0);
}

touch_start(integer total_number)
{
++Counter;
llSetText("Touched " + (string)Counter + "times",<1.0,0,0>,1.0);
//<1.0,0,0> = red
}
timer()
{
//Reset the Script (and the Counter)
llResetScript();
}
}


_____________________
21 is only half the truth...
Don't panic!
Herbert Toll
Registered User
Join date: 18 Dec 2006
Posts: 28
01-14-2007 18:37
thanks thats brilliant
Herbert Toll
Registered User
Join date: 18 Dec 2006
Posts: 28
01-15-2007 13:53
thnx for all the help guys, i put the script on and it worked but it didnt do what i needed because i didnt explain what i needed properly.
i have an abject with a landmark inside it. i need to set the object up so ppl can left click on it and take the landmark but also record how many ppl do this.

can that be done?
Jacques Groshomme
Registered User
Join date: 16 Mar 2005
Posts: 355
01-15-2007 14:19
Add the Landmark in question to the Contents of the object they'll be touching.

Then add this code (you'll need to edit Line 3 to reflect that actual name of the landmark):

CODE

integer Counter = 0;
integer TimerInterval = 86400; // 1 day (in seconds)
string landmarkName = "Landmark Name";

default
{
state_entry()
{
Counter = 0;
llSetText("Not Touched",<1.0,0,0>,1.0);
}

touch_start(integer total_number)
{
integer i;
for(i=0; i<total_number; i++) {
llGiveInventory(llDetectedKey(i), landmarkName);
++Counter;
}

llSetText("Touched " + (string)Counter + "times",<1.0,0,0>,1.0);
//<1.0,0,0> = red
}

timer()
{
//Reset the Script (and the Counter)
llResetScript();
}
}
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-15-2007 14:20
From: Herbert Toll
thnx for all the help guys, i put the script on and it worked but it didnt do what i needed because i didnt explain what i needed properly.
i have an abject with a landmark inside it. i need to set the object up so ppl can left click on it and take the landmark but also record how many ppl do this.

can that be done?


Yes of course it can, but it does help if you actually post what you really wanted! :)

However this forum is for help in writing scripts, not a free script writing service.
In the touch event you need to add a llGiveInventory of the landmark.
Jacques Groshomme
Registered User
Join date: 16 Mar 2005
Posts: 355
01-15-2007 14:24
From: Newgate Ludd
Yes of course it can, but it does help if you actually post what you really wanted! :)

However this forum is for help in writing scripts, not a free script writing service.
In the touch event you need to add a llGiveInventory of the landmark.



Oops, too late.

Although I did correct a problem with the previous scripts in that there was no checking for concurrent touches (that is, total_number was ever greater than one).
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-15-2007 15:08
From: Jacques Groshomme
Oops, too late.

Although I did correct a problem with the previous scripts in that there was no checking for concurrent touches (that is, total_number was ever greater than one).


LOL.
Herbert Toll
Registered User
Join date: 18 Dec 2006
Posts: 28
01-15-2007 16:18
thanks guys, i know its a bit cheeky but i am desperate and would of paid for a script.
my business is spiralling and i needed this script to give info to clients.

i am going to learn to program when i get chance.

thnx again
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-16-2007 01:15
From: Herbert Toll
thanks guys, i know its a bit cheeky but i am desperate and would of paid for a script.
my business is spiralling and i needed this script to give info to clients.

i am going to learn to program when i get chance.

thnx again



LOL, There is a products wanted forum for that! :)
If you want to learn then get stuck in and try, when you get stuck post here, thats what this forum is for.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-16-2007 01:25
From: Jacques Groshomme
Oops, too late.

Although I did correct a problem with the previous scripts in that there was no checking for concurrent touches (that is, total_number was ever greater than one).



Actually it was on purpose, for simplicity as much as anything. Although it is possible to get simultaneous clicks the likely hood is reasonably low and for this application unimportant.

A slight change to your landmark giver.
This version will give the first landmark it finds in inventory so no need to edit.

I'd also not bother with resetting the script, its not needed.

CODE

integer Counter = 0;
integer TimerInterval = 86400; // 1 day (in seconds)

Reset()
{
Counter = 0;
llSetText("Not Touched",<1.0,0,0>,1.0);
}


default
{
state_entry()
{
Reset();
}

touch_start(integer total_number)
{
string landmarkName = llGetInventoryName(INVENTORY_LANDMARK,0);
integer i;
for(i=0; i<total_number; i++)
{
llGiveInventory(llDetectedKey(i), landmarkName);
++Counter;
}

llSetText("Touched " + (string)Counter + "times",<1.0,0,0>,1.0);
}

timer()
{
Reset();
}
}
Herbert Toll
Registered User
Join date: 18 Dec 2006
Posts: 28
01-17-2007 02:22
cool, even better!!!!