Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Scripted email question

Vares Solvang
It's all Relative
Join date: 26 Jan 2005
Posts: 2,235
12-08-2006 00:31
Ok, I've been playing around with the email functions just to see how they work.

So I have this door that opens at the touch of a switch. When you touch the switch it just says "open" on chan 10. The door listens for an object named "switch" and then opens/closes when told too.


So I made a cube called "switch" and put a touch activated script in it that looks for emails then says the message on chan 10.

So, I email the cube a message that says "open", but the door doesn't respond. If I add a normal llSay command and tell it to just say open on chan 10, the door works.

So why doesn't it respond to the email message? When I have the script say the email message in open chat, it's a perfect: Switch: open.

I have no idea why the door won't respond to the email message though. Do you have any idea?

oh, I also couldn't get IF functions to work off of the email message body.
_____________________
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
12-08-2006 01:09
V,

Emails need to be polled for so you need to periodically call llGetNextEmail via a timer.

CODE

timer()
{
llGetNextEmail("", ""); // check for email with any subject/sender
}


Check this thread for a very primitive example lift i made that has exactly the same functionality you are talking about.
Vares Solvang
It's all Relative
Join date: 26 Jan 2005
Posts: 2,235
12-08-2006 01:19
I have it set to poll every time I touch it. I know it's getting the email, cause I have is set to tell me that it has.

But when it says the message in the email ("open";) on chan 10, the door doesn't respond.
_____________________
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
12-08-2006 01:31
Thats a known gotcha. The email message wont just be "open". SL appends 3 lines of location information to the message. us ethe follwoing to strip the SL applied info off



message = llDeleteSubString(message, 0, llSubStringIndex(message, "\n\n";) + 1);
Vares Solvang
It's all Relative
Join date: 26 Jan 2005
Posts: 2,235
12-08-2006 10:29
Ahhh, I saw that in the wiki, but didn't really understand what it meant. Thanks, I'll give it a try. :)
_____________________
Vares Solvang
It's all Relative
Join date: 26 Jan 2005
Posts: 2,235
12-08-2006 12:22
Wait...this is an email from me (using my normal email account), not another object, so there isn't any location data to strip off. And when it says the message in open chat, it's just the word "open". I don't understand why it's right with llSay(0,message), but not with llSay(10,message). The only difference is the channel. :confused:

edit:
It will work if I put the word open in as the subject line, and then say that on chan 10, but even using the "strip off the extra" line of code it still won't work with the message part. :confused: :confused:

Here is the script I am useing:

CODE



default
{
state_entry()
{
llSay(0,"ready");
}

touch_start(integer total_number)
{
llSay(0,"checking for email now, please wait");
llGetNextEmail("","");

}
email(string time, string address, string subj, string message, integer num_left)
{
llSay(0, "You've got mail! " + (string)num_left + " more waiting.");
//llSay(0, llList2CSV([time, address, subj, message]));
//message = llDeleteSubString(message, 0, llSubStringIndex(message, "\n\n") + 1);
llSay(0,message); //the message is said in open chat perfectly
llSay(10, message); //the door totally ignores this bit


}
}
_____________________
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
12-08-2006 13:39
From: Vares Solvang
Wait...this is an email from me (using my normal email account), not another object, so there isn't any location data to strip off. And when it says the message in open chat, it's just the word "open". I don't understand why it's right with llSay(0,message), but not with llSay(10,message). The only difference is the channel. :confused:

edit:
It will work if I put the word open in as the subject line, and then say that on chan 10, but even using the "strip off the extra" line of code it still won't work with the message part. :confused: :confused:

Here is the script I am useing:

CODE



default
{
state_entry()
{
llSay(0,"ready");
}

touch_start(integer total_number)
{
llSay(0,"checking for email now, please wait");
llGetNextEmail("","");

}
email(string time, string address, string subj, string message, integer num_left)
{
llSay(0, "You've got mail! " + (string)num_left + " more waiting.");
//llSay(0, llList2CSV([time, address, subj, message]));
//message = llDeleteSubString(message, 0, llSubStringIndex(message, "\n\n") + 1);
llSay(0,message); //the message is said in open chat perfectly
llSay(10, message); //the door totally ignores this bit


}
}


carriage returns and line feed characters?
get the receiver script to print out exactly what it receives in quotes or some other form of delimiter.
Vares Solvang
It's all Relative
Join date: 26 Jan 2005
Posts: 2,235
12-08-2006 13:45
ahhh, here is what that returns:

switch: here is the exact message I received 'open '

It looks like it defaults a space on the end of the message, so that is why the door ignores it. I will play with that and verify that is what it is and post the results here.


Thanks Newgy, my hero again! :D
_____________________
Vares Solvang
It's all Relative
Join date: 26 Jan 2005
Posts: 2,235
12-08-2006 14:06
It was definitely the extra space that was doing it. I added this line just before the llSay(10,message); line

message = llGetSubString(message, 0, llStringLength(message) - 2);

and it works now. :D
_____________________
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
12-08-2006 14:49
From: Vares Solvang
It was definitely the extra space that was doing it. I added this line just before the llSay(10,message); line

message = llGetSubString(message, 0, llStringLength(message) - 2);

and it works now. :D



You did did you????
Vares Solvang
It's all Relative
Join date: 26 Jan 2005
Posts: 2,235
12-08-2006 15:07
Well...after you told me too! I just posted that here so others could see it silly!


I already said that you were my hero, what more do you want?? :D
_____________________
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
12-08-2006 15:41
Cheese?