IM in Sensor Questions
|
|
Sharp Pike
Registered User
Join date: 24 Oct 2006
Posts: 12
|
07-30-2007 06:58
Hi, Below is a code snippet from a scanner script that I am working on. All seems to work fine except the llInstantMessage lines. I get the IM when I first rez the object but never again. Is there something about the sensor delay and the 2 sec delay for IMs that is causing a conflict? Didn't see anything on the wiki about this. I've got the sensor rate set to 2 secs. if that makes any difference. Thanks for your help. Sharp
sensor(integer num_detected) { integer x; string message = "";
for(x = 0; x < num_detected; x++) { integer find = llListFindList(names,[llDetectedName(x)]); if(find == -1) { names = names + [llDetectedName(x)]; times = times + [" SL Time:" + GetPSTTime()]; dates = dates + [" SL Date:" + GetPSTDate()];
if (llGetListLength(names) == MAX_LENGTH) { sendEmail(); } message = llDetectedName(x) + " visited on " + GetPSTDate() + " at "+ GetPSTTime(); llInstantMessage(llGetOwner(), message); llInstantMessage(otherkey, message);
}
}
}
|
|
RJ Source
Green Sky Labs
Join date: 10 Jan 2007
Posts: 272
|
07-30-2007 07:10
It's hard to tell without seeing the rest of the code, but on quick inspection, it looks like once your sensor code detects someone, it notifies the owner once, and then marks that person as already found, and no longer sends messages when it senses them. So if you're alone and testing this, it would message you once, and not again?
|
|
Sharp Pike
Registered User
Join date: 24 Oct 2006
Posts: 12
|
07-30-2007 07:21
Thanks RJ, I actually have some code that allows me to touch the scanner and list all the visitors so I can see that there are others who have visited but I never get the IM or an email when offline. I have offline IMs sent to email enabled in prefs. Any other thoughts? Sharp
|
|
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
|
07-30-2007 08:36
From: someone ... I never get the IM or an email when offline. I have offline IMs sent to email enabled in prefs.... [Edit: Ignore the following bit of misinformation. Sorry!] Object-sent llInstantMessage doesn't send IMs eligible for forwarding to email. To get that service while offline, llEmail will be needed, with a test for online status (probably llRequestAgentData, preferably gated by something like llKey2Name for cheap in-sim detection).
|
|
Catherine Dollinger
Registered User
Join date: 11 May 2007
Posts: 26
|
07-30-2007 08:40
Hi Sharp - I made a smilar script which worked ok, though not that flashy with email and the like, just IMs - and those IMs reached me as well by IM-to-mail. Taking that skeleton you would have a functional scanner to build on. Oh, yes - I raised the interval to about 30 or 60 seconds (I guess) to a) reduce lag b) more likely ignore quick passers And I added a notecard setup to list people to ignore...and a deny list to send IMs to those not wanted in a specific location Ok, it's not the best code ever produced - and some old testing lines are still in though commented out. Actually, as it's an offline version I have at hand, I can't gurantee that it compiles error-free  - But I think it's correct. If not let me know and I fetch the script from inworld later. Hope this helps a bit string productName = "CD Home Scanner"; key myOwner; key myNotecard; key myDenycard; integer iLine = 0; integer kLine = 0; string notecardID = "HomeScannerAllow"; string denycardID = "HomeScannerDeny"; list allowedList; list deniedList;
integer isInAllowedList( string name ) { integer listLen = llGetListLength(allowedList); integer retVal = FALSE; string entry; integer i; for (i = 0; i < listLen; i++) { entry = llList2String(allowedList, i); if ( entry == name ) { retVal = TRUE; } } return retVal; }
integer isInDeniedList( string name ) { integer listLen = llGetListLength(deniedList); integer retVal = FALSE; string entry; integer i; for (i = 0; i < listLen; i++) { entry = llList2String(deniedList, i); if ( entry == name ) { retVal = TRUE; } } return retVal; }
default { state_entry() { llSay(0, "Setting up " + productName ); myOwner = llGetOwner(); allowedList = []; llSay(0, "Reading notecard..."); myNotecard = llGetNotecardLine(notecardID, iLine); }
dataserver(key query_id, string data) { if (query_id == myNotecard) { // this is a line of our notecard if (data == EOF) { // llSay(0, "No more lines in notecard, read " + (string)iLine + " lines.");
state setup_denylist; } else { // increment line count // llSay(0, "Line " + (string)iLine + ": " + data); allowedList = allowedList + [data]; //request next line iLine++; myNotecard = llGetNotecardLine(notecardID, iLine); } } } }
state setup_denylist { state_entry() { deniedList = []; myDenycard = llGetNotecardLine(denycardID, kLine); }
dataserver(key query_id, string data) { if (query_id == myDenycard) { // this is a line of our notecard if (data == EOF) { // llSay(0, "No more lines in notecard, read " + (string)kLine + " lines.");
state setup_scanner; } else { // increment line count // llSay(0, "Line " + (string)kLine + ": " + data); deniedList = deniedList + [data]; //request next line kLine++; myDenycard = llGetNotecardLine(denycardID, kLine); } } } }
state setup_scanner { state_entry() { //---DEBUG: List read notecard entries integer listLen = llGetListLength(allowedList); string entry; integer i; llSay(0, "Notecard entries:"); for (i = 0; i < listLen; i++) { entry = llList2String(allowedList, i); llSay(0, entry); } listLen = llGetListLength(deniedList); llSay(0, "Denycard entries:"); for (i = 0; i < listLen; i++) { entry = llList2String(deniedList, i); llSay(0, entry); } //Set up a repeating sensor, that once a minute looks for any //avatars within a sphere with a 20 meter radius. llSensorRepeat("", "", AGENT, 20.0, PI, 60.0); } sensor(integer detected) //A sensor returns the first 16 items detected. { string msg; string name; integer num_foreign; integer i; msg = " avatars detected: "; num_foreign = 0; // Check the names of everyone the sensor detects for(i = 0; i < detected; i++) { name = llDetectedName(i); if ( !isInAllowedList(name) ) { msg = msg + llDetectedName(i) + " "; num_foreign++; if ( isInDeniedList(name) ) { llSay(0, name + ", you are not supposed to be here - please leave immediately!!!"); } } } msg = msg + "(" + (string)num_foreign + ")"; // Send message only if not listed names occured if ( num_foreign > 0 ) { llInstantMessage(myOwner, msg); } } no_sensor() { // llSay(0, "Nobody is around"); } }
|
|
Catherine Dollinger
Registered User
Join date: 11 May 2007
Posts: 26
|
07-30-2007 08:42
As for the forwarding - it's been about two months since I last used that script, has something changed in the behaviour of llInstantMessage sending to IM-toemail probably since then? We had some updates during that time ...
|
|
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
|
07-30-2007 09:10
From: Catherine Dollinger As for the forwarding - it's been about two months since I last used that script, has something changed in the behaviour of llInstantMessage sending to IM-toemail probably since then? We had some updates during that time ... Hmmm... the wiki says this works. I swear it's never worked for me, despite having email forwarding set and regularly getting other IMs to email.  Well, I'll try to debug my account, but in the meantime, ignore all I said. 
|
|
Sharp Pike
Registered User
Join date: 24 Oct 2006
Posts: 12
|
07-30-2007 10:06
Thanks Catherine and Qie, I'm very curious now since I don't see much difference from your script to mine as far as the llInstantMessage section in the sensor code. I think I'll play around some more and see if I can get to the bottom of this. One thought is that there might be something that prevents multiple IMs being sent as a spam preventative. I think I'll take out the second IM from my code and see if it helps. I'll also give a try to increasing the scan rate. I'll check it tonight when I get home and post back here. Thanks again for your help. Sharp
|
|
Catherine Dollinger
Registered User
Join date: 11 May 2007
Posts: 26
|
07-31-2007 01:32
Hi Sharp,
I agree that there's not much difference, I just intended to provide a complete sample. The IMs I got by mail were automatically grouped together when sent in a certain time period. I'll try to test the script again, will take me to setup the scanner in my home (though I'm officially not allowed in my current sim to prevent lag issues, but I guess for a short term installation it should be ok) and have a friend visit it in my absence. I'll be glad to post the results here.
|
|
Sharp Pike
Registered User
Join date: 24 Oct 2006
Posts: 12
|
Resolved
07-31-2007 05:57
Thanks to Catherine I've got this working now. It turns out that by increasing the scan rate from 2 secs to 20 secs the problem is solved. Apparently the 2 second delay for each llInstantMessage was causing a problem so to play it safe I'm always going to make sure that the scan rate is longer than the time needed to execute the code in the sensor routine. Probably not an exact way to do this but 20 seconds should be more than enough time to execute two IMs plus the other processing. Thanks again Catherine for your help!
|