Table of Contents

About

This is a variation of the cashier script but it is essentially a "dud" since it does not use primitive money like the original. It may be suitable to cases where the simulation does not benefit from two or more participants, thus emulating just the cashier part of the activity.

Set-up

The script is to be placed in a cashier machine with a retractable drawer. In this case, the drawer is link number 2, but that will vary between cashier builds. The root object must be shunted, its description must be set to total=0. After that the cashier responds to regular touches.

Code

cashier_dud.lsl
///////////////////////////////////////////////////////////////////////////
//  Copyright (C) Wizardry and Steamworks 2013 - License: GNU GPLv3      //
//  Please see: http://www.gnu.org/licenses/gpl.html for legal details,  //
//  rights of fair usage, 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, "&");
}
 
integer totalPaid = 0;
 
default {
    touch_start(integer num) {
        totalPaid = 0;
        llSetObjectDesc(wasKeyValueSet("total", "0", llGetObjectDesc()));
        llSetObjectDesc(wasKeyValueSet("key", llDetectedKey(0), llGetObjectDesc()));
        state enter;
    }
}
 
state enter {
    state_entry() {
        integer comChannel = (integer)("0x8" + llGetSubString(llGetOwner(), 0, 6));
        key a = wasKeyValueGet("key", llGetObjectDesc());
        llListen(comChannel, "", a, "");
        llTextBox(a, "\nPlease enter product price:\n", comChannel);
    }
    touch_start(integer num) {
        key a = wasKeyValueGet("key", llGetObjectDesc());
        if(a != llDetectedKey(0)) return;
        integer comChannel = (integer)("0x8" + llGetSubString(llGetOwner(), 0, 6));
        llListen(comChannel, "", a, "");
        llDialog(a, "Enter another product?", [ "Yes", "No" ], comChannel);
    }
    listen(integer channel, string name, key id, string message) {
        if(message == "Yes") {
            llTextBox(id, "\nPlease enter product price:\n", channel);
            return;
        }
        if(message == "No") jump final;
        llSetObjectDesc(wasKeyValueSet("total", (string)((integer)message+(integer)wasKeyValueGet("total", llGetObjectDesc())), llGetObjectDesc()));
        llDialog(id, "Enter another product?", [ "Yes", "No" ], channel);
        return;
@final;
        state open;
    }
}
 
state open {
    state_entry() {
        llSay(0, "The cashier is now open. The total amount the customer should pay: " + wasKeyValueGet("total", llGetObjectDesc()));
        //<-.20016, -.20799, -.10421>
        llSetLinkPrimitiveParams(2, [PRIM_POS_LOCAL, <.303145,.101628,-.000883>]);
    }
    touch_start(integer num) {
        state closed;
    }
}
 
state closed {
    state_entry() {
        llSetTimerEvent(1);
    }
    timer() {
        llSay(0, "Thank you for your patronage.");
        //<.07118, .07443, .10420>
        llSetLinkPrimitiveParams(2, [PRIM_POS_LOCAL, <.101338,.101619,-.000876>]);
        state default;
    }
}

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