|
Sherman Gustafson
Registered User
Join date: 5 Sep 2007
Posts: 28
|
11-15-2007 12:11
I am trying to develop an attendance script. Basically, when someone touches it for the first time, it starts a timer. Then when they are done looking at the presentation, the timer stops and will send an IM to the owner which tells the owner who viewed it and for how long.
I have it set up so when they first click it starts the timer. However, I have a sensor that will tell me when they walk away (more than 10m away). Once they walk away, I want the timer to stop and the IM to be sent.
However, I cannot figure out how to have the sensor send me an IM only once with their data. Whenever I do have it send an IM, it keeps sending it every time the timer loops. It doesn't seem like no_sensor() allows for IMs to be sent only once.
Any help would be greatly appreciated.
|
|
Nika Talaj
now you see her ...
Join date: 2 Jan 2007
Posts: 5,449
|
11-15-2007 12:28
Forgive me if I haven't understood your issue, but ... Instead of using no_sensor (that's a lot of events!) why not set a timer every time they are sensed, which goes off at an interval longer than your sensor rate? Reset the timer every time your sensor sees the person, and it won't go off until they are no longer in range.
At which time you send the IM, clear the timer, and you're done.
|
|
Beverly Ultsch
Registered User
Join date: 6 Sep 2007
Posts: 229
|
11-16-2007 05:34
The problem is that llNoSensor triggers every time nothing is sensed, so you need to remove the sensor. Try something like this.
string currentTouch = ""; key ownerKey; float startTime; float endTime;
default { state_entry() { ownerKey = llGetOwner(); } touch_start(integer total_number) { if(currentTouch == "") { currentTouch = llDetectedName(0); startTime = llGetWallclock(); llSensorRepeat(currentTouch, NULL_KEY, AGENT, 10.0, PI, 5.0); } }
sensor(integer total_number) { }
no_sensor() { llSensorRemove(); endTime = llGetWallclock(); llInstantMessage(ownerKey, currentTouch + " was here for " + (string)(endTime - startTime) + " seconds"); currentTouch = ""; } }
You may want to format the IM a bit more, but you get the general idea 
|
|
Sherman Gustafson
Registered User
Join date: 5 Sep 2007
Posts: 28
|
11-16-2007 09:50
Thanks for the help. I can't try it right now but I now understand what I did wrong.
I'll try in on Monday when I'm back at work.
Thanks!
|