Simple

From Second Life Wiki
Jump to navigation Jump to search

Simple E-mail sender Via Second life

With this simple script it´s possible send a e-mail from Second Life.

These scripts are honestly too simple for real use and shouldn't really be featured in the script library but at least they compile (unlike the original).

The owner only version is acceptable for real use since it will only respond to one user at a time.

Owner Only version

<lsl>// Say on channel 3 the email address, subject and message separated by pipes ("|")

// E.g. "/3 myemailaddress@myemailcompany.com|Hiya|How are you?"

integer channel = 3; // Channel on which to chat to the scripted object.

integer lis; // Handler for switching listening off when not needed.

key owner; // Used to filter who may use this device.

default {

   state_entry()
   {
       owner = llGetOwner();
   }
   changed(integer change)
   { // Remove if for open use
       if(change & CHANGED_OWNER)
       llResetScript();
   }
   touch_start(integer nd)
   {
       while(nd)
       {
           if(llDetectedKey(--nd) == owner)
           {
               lis = llListen(channel, "", owner, "");
               llOwnerSay("Listening");
           }
       }
   }
   listen(integer chan, string name, key id, string msg)
   {
       llListenRemove(lis);
       list details = llParseString2List(llStringTrim(msg, STRING_TRIM), ["|"], []);
       llEmail(llStringTrim(llList2String(details, 0), STRING_TRIM),
               llStringTrim(llList2String(details, 1), STRING_TRIM),
               llStringTrim(llList2String(details, 2), STRING_TRIM));
   }

}</lsl>

Any User version

This will listen to whoever touches the object this script is in. If it is touched again (before the first user has finished) the listen parameters will change so that only the second will be listened to.

<lsl>// Say on channel 3 the email address, subject and message separated by pipes ("|")

// E.g. "/3 myemailaddress@myemailcompany.com|Hiya|How are you?"

integer channel = 3; // Channel on which to chat to the scripted object.

integer lis; // Handler for switching listening off when not needed.

default {

   touch_start(integer nd)
   {
       lis = llListen(channel, "", llDetectedKey(0), "");
       llWhisper(0, "Listening on channel 3 to - " + llDetectedName(0));
   }
   listen(integer chan, string name, key id, string msg)
   {
       llListenRemove(lis);
       list details = llParseString2List(llStringTrim(msg, STRING_TRIM), ["|"], []);
       llEmail(llStringTrim(llList2String(details, 0), STRING_TRIM),
               llStringTrim(llList2String(details, 1), STRING_TRIM),
               llStringTrim(llList2String(details, 2), STRING_TRIM));
   }

}</lsl>

Really simple.