Difference between revisions of "Simple"

From Second Life Wiki
Jump to navigation Jump to search
(Simple e-mail sender via Second Life)
 
(→‎Simple E-mail sender Via Second life: Totally rewritten. The original was very poor and didn't compile (it wouldn't have worked if it did). I would scrap the whole page if I knew how.)
 
(One intermediate revision by one other user not shown)
Line 4: Line 4:
With this simple script it´s possible send a e-mail from Second Life.
With this simple script it´s possible send a e-mail from Second Life.


<lsl>
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).


default {
The owner only version is acceptable for real use since it will only respond to one user at a time.
  state_entry()
 
  {
=== Owner Only version ===
      llListen( 1, "", NULL_KEY, "" ); // differents chats for differents option (adress,subject, body)
 
      llListen( 2, "", NULL_KEY, "" );
<lsl>// Say on channel 3 the email address, subject and message separated by pipes ("|")
      llListen( 3, "", NULL_KEY, "" );
 
  }
// E.g. "/3 myemailaddress@myemailcompany.com|Hiya|How are you?"
  touch_start(integer total_number)
 
  {
integer channel = 3; // Channel on which to chat to the scripted object.
      llOwnerSay("/1 to adress!");
 
      llOwnerSay("/2 to subject!");
integer lis; // Handler for switching listening off when not needed.
      llOwnerSay("/3 to message!"); 
 
  }
key owner; // Used to filter who may use this device.
 
 
     listen( integer channel, string name, key id, string message )
default
{
     state_entry()
     {
     {
      string emailadress;
        owner = llGetOwner();
      string Subject;
    }
        string Body;
    changed(integer change)
          
    { // Remove if for open use
      if(channel ==1)
         if(change & CHANGED_OWNER)
         {
         llResetScript();
          emailadress = message;
    }
         
    touch_start(integer nd)
           
    {
      }
        while(nd)
      if(channel ==2)
         {
         {
             Subject = message;
             if(llDetectedKey(--nd) == owner)
         
            {
              
                lis = llListen(channel, "", owner, "");
                llOwnerSay("Listening");
             }
         }
         }
        if(channel ==3)
        {
            Body = message;
           
        }
        [llEmail][1](emailadress,Subject,Body); // Send the e-mail.
       
     }
     }
}
    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.


</lsl>
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.
Really simple.

Latest revision as of 10:02, 1 May 2010

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.