|
Nichiren Dinzeo
Registered User
Join date: 14 Feb 2007
Posts: 203
|
07-08-2008 19:56
Is it possible to limit an avatar to 1 touch every 2 hours or some other set time?
I have an object that I would like to allow unlimited avatars to touch but each only gets to touch it every 2 hours.
I suspect I would have to track the UUID of the avatar?
Thanks
|
|
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
|
07-08-2008 20:23
From: Nichiren Dinzeo I suspect I would have to track the UUID of the avatar?
yup
|
|
Nichiren Dinzeo
Registered User
Join date: 14 Feb 2007
Posts: 203
|
07-08-2008 21:10
yup  I just don't want to have to script sls and php to put that info into my external db and then retrieving and checking timestamps to do it. Anyone have a way of doing this in SL script it would save me a crap load of time.
|
|
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
|
07-08-2008 22:41
imagine a world where you have to save everything on semi volatile memory in 16k chunks, welcome to secondlife
now that being said you can cram about 200 uuids in a list (given your i/o scripting is small) which might do you fine, but also know after about the first 75 your already looking at long delays to access the data, and semi volatile might last you years ...
and also you dont have to use a database, you could use a flat file which is much simplier to implement, altho much less secure
before outside web access what i would (and did) do is just make a second script with a list defined in it, a linked message event and some basic read write functions to keep that scripts memory as free as possible
|
|
Nichiren Dinzeo
Registered User
Join date: 14 Feb 2007
Posts: 203
|
07-09-2008 10:17
thanks for your input. very informative. I guess I will take the time to manage this via our db. less Kludgy  From: Osgeld Barmy imagine a world where you have to save everything on semi volatile memory in 16k chunks, welcome to secondlife
now that being said you can cram about 200 uuids in a list (given your i/o scripting is small) which might do you fine, but also know after about the first 75 your already looking at long delays to access the data, and semi volatile might last you years ...
and also you dont have to use a database, you could use a flat file which is much simplier to implement, altho much less secure
before outside web access what i would (and did) do is just make a second script with a list defined in it, a linked message event and some basic read write functions to keep that scripts memory as free as possible
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
07-09-2008 10:20
Here is a template for handling only one touch per resident every MIN_TOUCH_PERIOD. It only remembers MAX_TOUCHERS residents though because of the limited amount of memory available. If more than MAX_TOUCHERS residents touch within a time period of MIN_TOUCH_PERIOD, then the script will start forgetting the first touches (and those residents can touch again). (NOTE: This script has not yet been compiled and may require a few minor fixes.) //// Constants
float MIN_TOUCH_PERIOD = 3600.0; // 1 hour integer MAX_TOUCHERS = 40;
//// Variables
list touchers = []; list touchTimes = []; // Negative if touch has ended integer nTouchers = 0;
//// Functions
handleTouchStart(integer touchIndex) { // Your code here }
handleTouch(integer touchIndex) { // Your code here }
handleTouchEnd(integer touchIndex) { // Your code here }
// Call this function from 'touch_start' only. If this touch is allowed, // handleTouchStart(detectIndex) will be called. filterTouchStart(integer detectIndex) { key toucher = llDetectedKey(detectIndex);
integer index = llListFindList(touchers, [ toucher ]); if (index >= 0) { float touchTime = llFabs(llList2Float(touchTimes, index)); if (llGetTime()-touchTime < MIN_TOUCH_PERIOD) { // Invalid touch; ignore return; }
removeToucher(index); } else if (nTouchers == MAX_TOUCHERS-1) { // Running out of memory; remove the earliest removeToucher(0); }
addToucher(toucher);
handleTouchStart(detectIndex); }
// Call this function from 'touch' only. If this touch is allowed, // handleTouch(detectIndex) will be called. filterTouch(integer detectIndex) { key toucher = llDetectedKey(detectIndex);
integer index = llListFindList(touchers, [ toucher ]); if (index < 0) { // Touch start was ignored before period expired; ignore return; }
float touchTime = llList2Float(touchTimes, index); if (touchTime < 0.0) { // Touch already ended; ignore return; }
handleTouch(detectIndex); }
// Call this function from 'touch_end' only. If this touch is allowed, // handleTouchEnd(detectIndex) will be called. filterTouchEnd(integer detectIndex) { key toucher = llDetectedKey(detectIndex);
integer index = llListFindList(touchers, [ toucher ]); if (index < 0) { // Touch start was ignored before period expired; ignore return; }
float touchTime = llList2Float(touchTimes, index);
if (llGetTime()-llFabs(touchTime) < MIN_TOUCH_PERIOD) { removeToucher(index); } else if (touchTime >= 0.0) { touchTimes = llListReplaceList( (touchTimes=[])+touchTimes, [ -touchTime ], index, index); }
if (touchTime < 0.0) { // Touch already ended; ignore return; }
handleTouchEnd(detectIndex); }
addToucher(key toucher) { touchers = (touchers=[])+touchers+[ toucher ]; touchTimes = (touchTimes=[])+touchTimes+[ llGetTime() ]; ++nTouchers; }
removeToucher(integer index) { touchers = llDeleteSubList((touchers=[])+touchers, index, index); touchTimes = llDeleteSubList((touchTimes=[])+touchTimes, index, index); --nTouchers; }
//// States
default { // ...
touch_start(integer nDetected) { integer i; for (i = 0; i < nDetected; ++i) { filterTouchStart(i); } }
touch(integer nDetected) { integer i; for (i = 0; i < nDetected; ++i) { filterTouch(i); } }
touch_end(integer nDetected) { integer i; for (i = 0; i < nDetected; ++i) { filterTouchEnd(i); } } }
|
|
Nichiren Dinzeo
Registered User
Join date: 14 Feb 2007
Posts: 203
|
07-10-2008 11:53
Hey thanks!!
|