Difference between revisions of "Simple"

From Second Life Wiki
Jump to navigation Jump to search
(→‎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.)
 
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.


To send an e-mail, you only need put this script in object and type in chat:
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).
/1 to write e-mail adress.
/2 to Write a Subject.
/3 to write your message.


This is just an example, you must change what you want!
The owner only version is acceptable for real use since it will only respond to one user at a time.
<lsl>


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