|
Hello Gynoid
Registered User
Join date: 3 Jun 2007
Posts: 6
|
06-03-2007 14:43
Hello,
I try to find a script which counts how many people touched an object. I am quite sure such a script already exists , but could not find it yet on the Wiki or Forum. Hope somebody can help me. Thanks!
Hello
|
|
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
|
06-03-2007 15:05
Any other requirements? For example, do you want to count EVERY click, or only do one click per avatar, do you want it to reset to zero after a while (e.g at midnight each night)?
_____________________
Computer (Mac Pro): 2 x Quad Core 3.2ghz Xeon 10gb DDR2 800mhz FB-DIMMS 4 x 750gb, 32mb cache hard-drives (RAID-0/striped) NVidia GeForce 8800GT (512mb)
|
|
Salvador Nakamura
http://www.sl-index.com
Join date: 16 Jan 2007
Posts: 557
|
06-03-2007 15:17
integer touched; default { state_entry() { llSetText("Times Touched: 0",<1,1,1>,1); } touch_start(integer no) { ++touched; llSetText("Times Touched:\n"+(string)touched,<1,1,1>,1); llOwnerSay("Times Touched: "+(string)touched); } } hope this helps ?
|
|
Hello Gynoid
Registered User
Join date: 3 Jun 2007
Posts: 6
|
06-03-2007 15:29
Thanks Salvador!
With regards to other requirements Haravikk: yes. I want to count only uniek avatars and I would like to send the number of touches to my email once a day. So yes it would be required then to reset to zero after the email report has been send.
Thanks for your support!
|
|
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
|
06-04-2007 05:32
Here's a script that I use modified slightly: integer touches; list touchedBy; integer maxListSize;
setTimer() { float time = 86400.0 - llGetGMTclock(); // Time remaining to this GMT day if (time < 3600.0) time += 86400.0; // If less than an hour, we may as well wait a day llSetTimerEvent(time); }
default { state_entry() { // Calculate roughly how many keys we can store, we'll be generous maxListSize = llGetFreeMemory() / 130; // Keys are about 61 bytes, add some extra // and double so we have plenty space llOwnerSay("Cache size is "+(string)maxListSize+" avatars"); setTimer(); } touch_start(integer x) { key id = llDetectedKey(0); if (llListFindList(touchedBy, [id]) < 0) { // New avatar ++touches; touchedBy += [id]; // If the list has grown too large then trim it down x = (touchedBy != []) - maxListSize; if (x > 0) touchedBy = llList2List(touchedBy, x, -1); } } timer() { touchedBy = []; // Clear the list llInstantMessage(llGetOwner(), "/me was touched "+(string)touches+" times today"); // llEmail(<my_address>, "Touches", "Received "+(string)touches+" today"); setTimer(); } } This script uses instant messages, so if you're on SL you'll get it in-world, otherwise (if you have IM to e-mail set) then you will receive the message via e-mail. If you want it stricly e-mail only then change the timer() block to this: timer() { touchedBy = []; // Clear the list // llInstantMessage(llGetOwner(), "/me was touched "+(string)touches+" times today"); llEmail(<my_address>, "Touches", "Received "+(string)touches+" today"); setTimer(); }I can't guarantee the timing, it's the same thing I use but it's sometimes off by 20 minutes or so (early, much to my confusion), but it's consistent at least. Hope it works as you want!
_____________________
Computer (Mac Pro): 2 x Quad Core 3.2ghz Xeon 10gb DDR2 800mhz FB-DIMMS 4 x 750gb, 32mb cache hard-drives (RAID-0/striped) NVidia GeForce 8800GT (512mb)
|
|
Hello Gynoid
Registered User
Join date: 3 Jun 2007
Posts: 6
|
06-04-2007 16:06
Haravikk this is great! I need to test it, but as far as I can see, it contains the functionality I need. Will let you know when it works. Thanks! Regards, Hello
|
|
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
|
06-05-2007 00:17
Crap, just noticed a mistake, I've gone and deleted too much! In the timer() event, at the end put: touches = 0;
Currently the script I posted only clears the touchedBy list but keeps on counting touches, eep! Otherwise I can verify it works perfectly fine (simply forced the time to be 30 seconds and got some touches in =)
_____________________
Computer (Mac Pro): 2 x Quad Core 3.2ghz Xeon 10gb DDR2 800mhz FB-DIMMS 4 x 750gb, 32mb cache hard-drives (RAID-0/striped) NVidia GeForce 8800GT (512mb)
|