User:Trinity Coulter/Dropbox script

From Second Life Wiki
Jump to navigation Jump to search

Drop items onto the script and it will send to the specified key. Must change the name too, or it will read the wrong name to the person in the touch help text.

<lsl> //change these 2 lines, sendto_name and sendto_key string sendto_name = "Newbie Avatar"; key sendto_key = "00000000-0000-0000-0000-000000000000";

string sendto_email = ""; //if left blank, box will IM only

string name_of_notecard_to_keep = "Just a note"; //must match case of letters

default {

   state_entry()
   {
       llAllowInventoryDrop(TRUE);
   }

   touch_start(integer total_number)
   {
       llSay(0, "Drop stuff on me to send to " + sendto_name + ".");
   }

   changed(integer change)
   {
       if (change & CHANGED_INVENTORY)
       {
           integer x;
           for (x = 0; x < llGetInventoryNumber(INVENTORY_ALL); x++)
           {
               if (llGetInventoryName(INVENTORY_ALL, x) != llGetScriptName() && llGetInventoryName(INVENTORY_ALL, x) != name_of_notecard_to_keep)
               {
                   llGiveInventory(sendto_key, llGetInventoryName(INVENTORY_ALL, x));

                   if (sendto_email == "")
                   {
                       llInstantMessage(sendto_key, "Sent \'" + llGetInventoryName(INVENTORY_ALL, x) + "\' from " + llKey2Name(llGetOwner()) + "'s dropbox.");
                   }
                   else
                   {
                       llInstantMessage(sendto_key, "Sent \'" + llGetInventoryName(INVENTORY_ALL, x) + "\' from " + llKey2Name(llGetOwner()) + "'s dropbox. (email also sent)");
                       llEmail(sendto_email, "SL Dropbox Notification", "Sent \'" + llGetInventoryName(INVENTORY_ALL, x) + "\' from " + llKey2Name(llGetOwner()) + "'s dropbox.");
                   }

               }
           }

           x = 0;
           float add_one = llStringLength(name_of_notecard_to_keep);
           if (add_one > 0) { add_one = 1;}
           while (llGetInventoryNumber(INVENTORY_ALL) > 1 + add_one)
           {

               if (llGetInventoryName(INVENTORY_ALL, x) == llGetScriptName() || llGetInventoryName(INVENTORY_ALL, x) == name_of_notecard_to_keep)
               {
                   x++;
               }
               else
               {
                   llRemoveInventory(llGetInventoryName(INVENTORY_ALL, x));
               }
           }

       }

   }

}

</lsl>