Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

email event not acting predictably, bug or misunderstood "feature"?

Dragon Eccleston
Registered User
Join date: 25 Dec 2005
Posts: 42
08-13-2006 07:31
I've been noticing that sometimes an llGetNextEmail() call in a child prim will trigger the email() events in both that child and sometimes the root prim as well. Text code:

email reciever:
CODE

default
{
state_entry()
{
llSetTimerEvent(5);
llGetNextEmail("", (string)llGetLinkNumber()); //Get email sent to this prim only
}
timer()
{
llGetNextEmail("", (string)llGetLinkNumber()); //Get email sent to this prim only
}
email(string time, string address, string subject, string message, integer num_remaining)
{
if ((integer)subject == llGetLinkNumber())
llOwnerSay("Prim " + (string)llGetLinkNumber() + " asked for this e-mail, and there are " + (string)num_remaining + " left for me to get!");
else
llOwnerSay("Prim " + (string)llGetLinkNumber() + " got an e-mail sent to prim " + subject + ", I think I have " + (string)num_remaining + " left, but I probably don't...");
if (num_remaining)
llGetNextEmail("", (string)llGetLinkNumber()); //Get email sent to this prim only
}
}


email sender:
CODE

integer NUM_MAILS = 1; // lets you vary the number of test messages it sends

default
{
state_entry()
{
integer i;
for (i = 0; i < NUM_MAILS; ++i)
llEmail((string)llGetKey() + "@lsl.secondlife.com", (string)llGetLinkNumber(), "testing one two three"); // Send email to containing prim with the link number as the subject to differentiate all the emails
llOwnerSay("emails sent");
llRemoveInventory(llGetScriptName());
}
}


Now create an object with at least 3 prims, place the email reciever scripts in all prims. Here's where things get funny, because SL doesn't always redirect the events, just sometimes, and it doesn't always redirect them from all child prims, sometimes just one. First drop a copy of email sender in each prim to verify it works, should get this:

[19:39] Object: Prim 1 asked for this e-mail, and there are 0 left for me to get!
[19:39] Object: Prim 2 asked for this e-mail, and there are 0 left for me to get!
[19:40] Object: Prim 3 asked for this e-mail, and there are 0 left for me to get!

Tho you may start getting the error messages right away, if you don't start playing with the scripts, delete/re-add the reciever scripts, add multiple sender scripts, do any other strange thing, after a while you'll probably start getting things like this:

[19:39] Object: Prim 1 asked for this e-mail, and there are 0 left for me to get!
[19:39] Object: Prim 2 asked for this e-mail, and there are 0 left for me to get!
[19:40] Object: Prim 1 got an e-mail sent to prim 3, I think I have 0 left, but I probably don't...
[19:40] Object: Prim 3 asked for this e-mail, and there are 0 left for me to get!

Which was the real output from my test initialization above, then I went back after I typed this up and suddenly prim 3 was fine, however dropping a few email senders in prim 2 resulted in the following:

[19:42] Object: Prim 3 asked for this e-mail, and there are 0 left for me to get!
[19:42] Object: Prim 3 asked for this e-mail, and there are 0 left for me to get!
[19:42] Object: Prim 1 got an e-mail sent to prim 2, I think I have 1 left, but I probably don't...
[19:42] Object: Prim 2 asked for this e-mail, and there are 1 left for me to get!
[19:42] Object: Prim 1 got an e-mail sent to prim 2, I think I have 0 left, but I probably don't...
[19:42] Object: Prim 2 asked for this e-mail, and there are 0 left for me to get!

At first prim 1 was getting prim 3's email events, now it's getting prim 2's, but not prim 3's. Oh wait I just checked again:

[19:45] Object: Prim 1 got an e-mail sent to prim 2, I think I have 0 left, but I probably don't...
[19:45] Object: Prim 2 asked for this e-mail, and there are 0 left for me to get!
[19:45] Object: Prim 1 got an e-mail sent to prim 3, I think I have 0 left, but I probably don't...
[19:45] Object: Prim 3 asked for this e-mail, and there are 0 left for me to get!

all child email events are being registered by the root prim, and now:

[19:47] Object: Prim 3 asked for this e-mail, and there are 0 left for me to get!
[19:47] Object: Prim 2 asked for this e-mail, and there are 0 left for me to get!
[19:48] Object: Prim 3 asked for this e-mail, and there are 0 left for me to get!
[19:48] Object: Prim 2 asked for this e-mail, and there are 0 left for me to get!

no child email events are being registered by the root prim. In less than 10 minutes of writing this post the email event in the root prim has demonstrated 4 different behaviors... I presume the last behavior is the correct one, the email events going to the child and the child alone. Has anyone else seen this?

As a side note I attached the object being tested to my HUD to make it easier to work with, however I've done testing with objects on the ground and seen similar results.

No mention of proper behavior in the wiki, I'm really not sure how this is supposed to work, as it seems to work in every possible way with no code change, seemingly on its own whim. Not sure I like the possibility of code having whims...
Torley Linden
Enlightenment!
Join date: 15 Sep 2004
Posts: 16,530
08-16-2006 11:13
I'm asking about this... :)
_____________________