Motivation

This script is a free implementation of a mail system which can be used to deliver items to a list of subscribers compatible with the Greeter I wrote but also works perfectly independently of it. It allows you to maintain a subscription list, it implements an access list so that several people are allowed shared access to the device, it sends a greeting before delivering items and after the item has been delivered and also notifies the person who triggered the delivery system of the current progress of the system.

This is a very compact script which does not need too much setting up and can be placed in whatever prim you like (if need be, you could also drop it in a HUD). The controls are simple: the menu item Mail! starts sending all the items the prim contains to every subscriber on the list. Another menu item is Subs which will display a list of your current subscribers.

ChangeLog

7 March 2013

  • Script maintenance.

Setting Up

To set up the system, create two notecards:

First, create a notecard called Subscribers and fill it with avatar key names / avatar names line-by-line following the following format. For example, the following are the contents of the notecard "Subscribers" which contains two avatars keys and their names separated by a hash sign:

1ad33407-a792-476d-a5e3-06007c0802bf#Morgan LeFay
82c73d6d-facf-4332-b17b-06d8cd66a116#Frank Black

Next, create a notecard called 'Access' and enter the avatar names line-by-line which will have access to the mailing system. For example, in order to grant myself access to the system, my access list looks like this:

Morgan LeFay
Frank Black

Thus letting both Morgan LeFay and Frank Black manipulate the script. Afterwards, add the script below to the prim and then add whatever items you want to be delivered. Please note that you can send any item you want, it can be a sound, it can be a notecard, it can be an object, it can be whatever you like. The script itself does not send the notecards Subscribers and Access, as well as itself to the subscribers. The script should automatically pick up inventory changes. Thus, if you want an item removed from being sent to the subscribers, simply remove it from the prim's inventory. The mailbox system also asks you to confirm the objects being sent. You can chose to Confirm or Abort. If you Confirm, the script will start sending the items in its inventory to every subscriber sequentially and will also notify you via IM of its progress.

Applications

Here's a list of possible applications I could think of:

  • If you own a shop and wish to deliver gifts to customers, you can use this system to mass-send them.
  • Good for groups or role-play SIMs.

Code

This script was tested and works on OpenSim version 0.7.4!

mail.lsl
///////////////////////////////////////////////////////////////////////////
//  Copyright (C) Wizardry and Steamworks 2011 - License: GNU GPLv3      //
//  Please see: http://www.gnu.org/licenses/gpl.html for legal details,  //
//  rights of fair usage, the disclaimer and warranty conditions.        //
///////////////////////////////////////////////////////////////////////////
 
list sList = [];
list nList = [];
list aList = [];
list pList = [];
key sQuery = NULL_KEY;
key aQuery = NULL_KEY;
integer sLine = 0;
integer aLine = 0;
integer comHandle = 0;
 
readSetup() {
    aList = [];
    sList = [];
    nList = [];
    integer cards = 0;
    integer i = llGetInventoryNumber(INVENTORY_NOTECARD)-1;
    do {
        if(llGetInventoryName(INVENTORY_NOTECARD, i) == "Subscribers" || llGetInventoryName(INVENTORY_NOTECARD, i) == "Access") ++cards;
        if(cards == 2) jump found_cards;
    } while(--i>-1);
    return;
@found_cards;
    sLine = 0;
    aLine = 0;
    sQuery = llGetNotecardLine("Subscribers", sLine);
    aQuery = llGetNotecardLine("Access", aLine);
}
 
readPost() {
    pList = [];
    integer i = llGetInventoryNumber(INVENTORY_ALL)-1;
    do {
        if(llGetInventoryName(INVENTORY_ALL, i) == "Subscribers") jump continue;
        if(llGetInventoryName(INVENTORY_ALL, i) == "Access") jump continue;
        if(llGetInventoryName(INVENTORY_ALL, i) == llGetScriptName()) jump continue;
        pList += llGetInventoryName(INVENTORY_ALL, i);
@continue;
    } while(--i>-1);
}
 
sendPost(key id) {
    integer i = llGetListLength(sList)-1;
    do {
        llInstantMessage(llList2Key(sList, i), "Hello " + llList2String(nList, i) + "! We have a delivery for you, a package containing " + llDumpList2String(pList, ", ") + ". Please accept the items as they are being delivered...");
        integer j = 0;
        do {
            llGiveInventory(llList2Key(sList, i), llList2String(pList, j));
            llInstantMessage(id, "Sending: " + llList2String(pList, j) + " to " + llList2String(nList, i)); 
        } while(--j>-1);
        llInstantMessage(llList2Key(sList, i), "Have a nice day " + llList2String(nList, i) + "! Thank you for subscribing with us.");
    } while(--i>-1);
}
 
default
{
    state_entry()
    {
        readSetup();
        readPost();
    }
 
    changed(integer change) {
        if(change & CHANGED_INVENTORY) llResetScript();
    }
 
    touch_start(integer total_number)
    {
        if(llListFindList(aList, (list)llDetectedName(0)) == -1) return;
 
        integer comChannel = ((integer)("0x"+llGetSubString((string)llGetKey(),-8,-1)) & 0x3FFFFFFF) ^ 0xBFFFFFFF;
        comHandle = llListen(comChannel, "", llDetectedKey(0), "");
        llDialog(llDetectedKey(0), "Welcome to the mailer, please select an action: ", [ "Mail!", "Subs" ], comChannel);
    }
 
    listen(integer channel, string name, key id, string message) {
        if(llListFindList(aList, (list)name) == -1) return;
 
        if(message == "Mail!") {
 
            string post = "";
            integer i = llGetListLength(pList) -1;
            do {
                post += (string)i + ".) " + llList2String(pList, i) + "\n";
            } while(--i>-1);
            llDialog(id, "Please confirm sending the following items to all the listed subscribers:\n" + post, [ "Confirm", "Abort" ], channel);
            return;
        }
 
        if(message == "Subs") {
            string subs;
            integer j = llGetListLength(nList)-1;
            do {
                subs += llList2String(nList, j);
                if(j+1<llGetListLength(nList)) {
                    subs += ", ";
                    jump continue;
                }
                subs += ".";
@continue;
            } while(--j>-1);
            llInstantMessage(id, "Your subscribers are: " + subs);
        }
 
        if(message == "Confirm") {
            sendPost(id);
        }
 
        llListenRemove(comHandle);
    }
 
    dataserver(key query_id, string data) {
        if(query_id == aQuery) {
            if(data == EOF) return;
            if(data == "") jump next_access;
            aList += (list) data;
@next_access;
            aQuery = llGetNotecardLine("Access", ++aLine);
        }
        if(query_id == sQuery) {
            if(data == EOF) return;
            if(data == "") jump next_subscriber;
            sList += llList2List(llParseString2List(data, ["#"], [""]), 0, 0);
            nList += llList2List(llParseString2List(data, ["#"], [""]), 1, 1);
@next_subscriber;
            sQuery = llGetNotecardLine("Subscribers", ++sLine);
        }
    }
}

secondlife/mail.txt ยท Last modified: 2022/11/24 07:46 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.