LSL Object or Item Giver Script for Second Life, OpenSim

Second Life or OpenSim LSL Script to Turn a Prim into a Item, object, or Notecard Delivery System with Notification of Delivery

Place this script in a prim, like a sign, and it becomes a item delivery system.  Great for delivering free items like demos, freebies, or notecards.  When touched in-world at Second Life®  it will deliver a selected item from the prim’s inventory to the avatar that touched it.  Includes optional features that will cause the prim to glow slightly when touched providing a visual clue as to the action.  The script also has a notification option, when activated the script will send an IM and or email message to you notifying you that an item was given away and also giving you the name of the avatar who it was given to.  (Important: The notification feature only works if you own the parcel the object/item giver is on.)

Note: email messages are much faster and more reliable if you want a record of who has touched the delivery prim and received your item.  That is why the option for direct email notification is included.  I recommend that you use the email notification and turn off the IM notification.

  1. Make a prim to serve as the “item giver” and create a new script in it.
  2. Edit the new script, delete the default script, and copy and paste the script below into it.
  3. Edit the section of the script labeled “Settings”.
  4. Save the script.  Then rename it.
  • If you don’t want a message chatted to the avatar when they touch the prim, delete all text and spaces between the quotes in the message text string (use a blank message.)   Ie: enter “” as the message.  If you put a space between the quotes it will chat a empty space!  If there is no space it will not chat any message at all (it will be silent).
  • The name of the item to be delivered must be the exact name of the item and there must not be two items in the prim’s inventory with the same name.  Ie: there can’t be an object and a notecard with the same name in the Contents folder of the delivery prim.
  • Glow, notify (IM), and emailme settings all need a value of  0 to turn them off.  Entering FALSE (all upper case) will also turn the features off.  Entering TRUE will turn them on.   Any numeric value other than 0 will turn them on.  Any other values will result in an error message when you save the script.
  • If email notification is on, the script sleeps/pauses for 20 seconds after giving an item away.  Second Life inserts the email delay to make scripts impractical for delivering email spam.  Note: Notifications only work if the item giver owner is the same as the parcel owner.  SL will block the message otherwise to prevent using this as a spam generator.
  • Error message?  The error message will give you the line that the compiler believes has the error.  Sometimes the error is on the previous line, often it is caused by a missing semi-colon (;).  Double check for typos in your setup information!  That is the primary cause of errors and delivery failures.  Be sure to test the delivery system using an avatar that is NOT the owner!
Here’s the script to copy and paste into the prim:

//Item Giver Script
//by Leaf Illusion
//Please visit my website:
//Script Description:
//Make a prim to serve as the "item giver" and place this script in it.
//When the "item giver" containing this script is touched, the item giver will
//glow and the script will give the specified item in inventory to the toucher.
//It will then notify you by IM and/or email with the name of the item that
//was given away and the name of the avatar it was given to.

string message = "Your delivery message"; //Enter message to be chatted to recipient. Use "" for no message.
string ItemName = "Name of item"; //Enter name of inventory item to be delivered.
string emailAddress = ""; //Enter your email address if you want email notification.
integer glow = 1; // 1 is on, 0 turns off glow.
integer notify = 0; // 1 is on, 0 turns off IM notification of item given.
integer emailme = 1; // 1 is on, 0 turns off email notification of item given.
//Be sure to place the object to be given in the inventory Contents folder.

//No need to change anything below this line.

key owner;
        owner = llGetOwner();
        llSetClickAction (CLICK_ACTION_TOUCH);
    touch_start(integer n)
        if (glow) llSetPrimitiveParams([PRIM_GLOW, ALL_SIDES, 0.10]);
        if (notify) llInstantMessage(owner, (string) llDetectedName(0) + " was given " + ItemName ); 
        if (glow) llSetPrimitiveParams([PRIM_GLOW, ALL_SIDES, 0.0]);
        if (emailme) llEmail(emailAddress, "Item delivery",(string) llDetectedName(0) + " was given " + ItemName);

No comments:

Post a Comment