Note

The currency is represented by named primitives. The picture below is an example of a 100 value bill.

The name is set to the value of the bill, in the example below, since the primitive is worth 100, the name of the object is set to:

money=100

Naming the primitive is necessary since that string will get processed by the key-value data system that will take care of calculating the returns.

Code

cashier_money.lsl
//////////////////////////////////////////////////////////
// (c) Wizardry and Steamworks - 2013, License GPLv3    //
// Please see: http://www.gnu.org/licenses/gpl.html     //
// for legal details, rights of fair usage and          //
// the disclaimer and warranty conditions.              //
//////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////
//    Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3    //
///////////////////////////////////////////////////////////////////////////
string wasKeyValueGet(string var, string kvp) {
    list dVars = llParseString2List(kvp, ["&"], []);
    do {
        list data = llParseString2List(llList2String(dVars, 0), ["="], []);
        string k = llList2String(data, 0);
        if(k != var) jump continue;
        return llList2String(data, 1);
@continue;
        dVars = llDeleteSubList(dVars, 0, 0);
    } while(llGetListLength(dVars));
    return "";
}
 
///////////////////////////////////////////////////////////////////////////
//    Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3    //
///////////////////////////////////////////////////////////////////////////
string wasKeyValueSet(string var, string val, string kvp) {
    list dVars = llParseString2List(kvp, ["&"], []);
    if(llGetListLength(dVars) == 0) return var + "=" + val;
    list result = [];
    do {
        list data = llParseString2List(llList2String(dVars, 0), ["="], []);
        string k = llList2String(data, 0);
        if(k == "") jump continue;
        if(k == var && val == "") jump continue;
        if(k == var) {
            result += k + "=" + val;
            val = "";
            jump continue;
        }
        string v = llList2String(data, 1);
        if(v == "") jump continue;
        result += k + "=" + v;
@continue;
        dVars = llDeleteSubList(dVars, 0, 0);
    } while(llGetListLength(dVars));
    if(val != "") result += var + "=" + val;
    return llDumpList2String(result, "&");
}
 
default
{
    state_entry() {
        integer comChannel = (integer)("0x8" + llGetSubString(llGetCreator(), 0, 6));
        llSetObjectDesc(wasKeyValueSet("owner", llGetOwner(), llGetObjectDesc()));
        llListen(comChannel, "", "", "");
    }
    listen(integer channel, string name, key id, string message) {
        llOwnerSay(message);
        if(wasKeyValueGet("owner", message) != wasKeyValueGet("owner", llGetObjectDesc())) return;
        if(wasKeyValueGet("money", message) != "die") return;
        if(wasKeyValueGet("amount", message) != wasKeyValueGet("money", llGetObjectName())) return;
        llDie();
    }
    on_rez(integer num) {
        llResetScript();
    }
}

secondlife/cashier/money.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.