Code

pay_to_strip.lsl
///////////////////////////////////////////////////////////////////////////
//  Copyright (C) Wizardry and Steamworks 2015 - 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    //
///////////////////////////////////////////////////////////////////////////
list spinChars = [ ".oOo", "oOo.", "Oo.o", "o.oO" ];
string wasSpin() {
    string text = llList2String(llGetLinkPrimitiveParams(LINK_THIS, [PRIM_TEXT]), 0);
    do {
        string tok = llGetSubString(text, llStringLength(text) - 1, llStringLength(text) - 1);
        if (!~llListFindList(spinChars, (list)tok) && tok != "\n" && tok != "[" && tok != "]") jump show;
        text = llDeleteSubString(text, llStringLength(text) - 1, llStringLength(text) - 1);
    } while (llStringLength(text));
@show;
    string next = llList2String(spinChars, 0);
    spinChars = llDeleteSubList(spinChars, 0, 0);
    spinChars += next;
    return "[" + next + "]";
}
 
///////////////////////////////////////////////////////////////////////////
//    Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3    //
///////////////////////////////////////////////////////////////////////////
integer wasMenuIndex = 0;
list wasDialogMenu(list input, list actions, string direction) {
    integer cut = 11 - wasListCountExclude(actions, [""]);
    if (direction == ">" && (wasMenuIndex + 1) * cut + wasMenuIndex + 1 < llGetListLength(input)) {
        ++wasMenuIndex;
        jump slice;
    }
    if (direction == "<" && wasMenuIndex - 1 >= 0) {
        --wasMenuIndex;
        jump slice;
    }
@slice;
    integer multiple = wasMenuIndex * cut;
    input = llList2List(input, multiple + wasMenuIndex, multiple + cut + wasMenuIndex);
    input = wasListMerge(input, actions, "");
    return input;
}
 
///////////////////////////////////////////////////////////////////////////
//    Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3    //
///////////////////////////////////////////////////////////////////////////
integer wasListCountExclude(list input, list exclude) {
    if (llGetListLength(input) == 0) return 0;
    if (llListFindList(exclude, (list)llList2String(input, 0)) == -1)
        return 1 + wasListCountExclude(llDeleteSubList(input, 0, 0), exclude);
    return wasListCountExclude(llDeleteSubList(input, 0, 0), exclude);
}
 
///////////////////////////////////////////////////////////////////////////
//    Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3    //
///////////////////////////////////////////////////////////////////////////
list wasListMerge(list l, list m, string merge) {
    if (llGetListLength(l) == 0 && llGetListLength(m) == 0) return [];
    string a = llList2String(m, 0);
    if (a != merge) return [ a ] + wasListMerge(l, llDeleteSubList(m, 0, 0), merge);
    return [ llList2String(l, 0) ] + wasListMerge(llDeleteSubList(l, 0, 0), llDeleteSubList(m, 0, 0), merge);
}
 
///////////////////////////////////////////////////////////////////////////
//    Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3    //
///////////////////////////////////////////////////////////////////////////
string wasKeyValueGet(string k, string data) {
    if (llStringLength(data) == 0) return "";
    if (llStringLength(k) == 0) return "";
    list a = llParseStringKeepNulls(data, ["&", "="], []);
    integer i = llListFindList(llList2ListStrided(a, 0, -1, 2), [ k ]);
    if (i != -1) return llList2String(a, 2 * i + 1);
    return "";
}
 
// RLV wearables
list WEARABLES = [ "gloves", "jacket", "pants", "shirt", "shoes", "skirt", "socks", "underpants", "undershirt", "skin", "eyes", "hair", "shape" ];
// RLV attachments
list ATTACHMENTS = [ "none", "chest", "skull", "left shoulder", "right shoulder", "left hand", "right hand", "left foot", "right foot", "spine", "pelvis", "mouth", "chin", "left ear", "right ear", "left eyeball", "right eyeball", "nose", "r upper arm", "r forearm", "l upper arm", "l forearm", "right hip", "r upper leg", "r lower leg", "left hip", "l upper leg", "l lower leg", "stomach", "left pec", "right pec", "center 2", "top right", "top", "top left", "center", "bottom left", "bottom", "bottom right", "neck", "root" ];
 
// The version string.
string VERSION = "\n                    Welcome to the Strip Jar.\nCreated in 2015 by Wizardry and Steamworks\n                 11 February 2015: Version: 1.0\n\n";
 
// for notecard reading
integer line = 0;
 
// key-value data will be read into this list
list tuples = [];
 
// instance variables
key client = NULL_KEY;
list menu = [];
integer price = 0;
string item = "None";
string agent = "Nobody";
integer given = 0;
 
default {
    state_entry() {
        llSetText(
            "Requesting debit permissions...",
            < 1, 1, 0 >,
            1
        );
        // request debit permission for giving money back
        llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
    }
    run_time_permissions(integer perm) {
        // switch into configuration state
        if (perm & PERMISSION_DEBIT) state configure;
        llOwnerSay("This gizmo needs debit permissions in order to pay people back. Cannot proceed.");
        llOwnerSay("Please touch this gizmo to request permissions again.");
        llSetText(
            "No debit permissions granted.",
            < 1, 0, 0 >,
            1
        );
    }
    touch_start(integer num) {
        llResetScript();
    }
    changed(integer change) {
        if (change & CHANGED_INVENTORY || change & CHANGED_OWNER) {
            llResetScript();
        }
    }
    on_rez(integer num) {
        llResetScript();
    }
}
 
state configure {
    state_entry() {
        if (llGetInventoryType("configuration") != INVENTORY_NOTECARD) {
            llSay(DEBUG_CHANNEL, "Sorry, could not find an inventory notecard.");
            return;
        }
        llSetText(
            "Reading configuration notecard, please wait...\n" + wasSpin(),
            < 1, 1, 0 >,
            1
        );
        llGetNotecardLine("configuration", line);
    }
    dataserver(key id, string data) {
        if (data == EOF) { // invariant: length(tuples) % 2 == 0
            if (llGetListLength(tuples) % 2 != 0) {
                llSay(DEBUG_CHANNEL, "Sorry, there was an error reading the configuration notecard.");
                return;
            }
            llSetText(
                "Configuration notecard read successfully!",
                < 0, 1, 0 >,
                1
            );
            state check;
        }
        if (data == "") jump continue;
        integer i = llSubStringIndex(data, "#");
        if (i != -1) data = llDeleteSubString(data, i, -1);
        list o = llParseString2List(data, ["="], []);
        // get rid of starting and ending quotes
        string k = llDumpList2String(
            llParseString2List(
                llStringTrim(
                    llList2String(
                        o,
                        0
                        ),
                    STRING_TRIM),
                ["\""], []
                ), "\"");
        string v = llDumpList2String(
            llParseString2List(
                llStringTrim(
                    llList2String(
                        o,
                        1
                        ),
                    STRING_TRIM),
                ["\""], []
                ), "\"");
        if (k == "" || v == "") jump continue;
        tuples += k;
        tuples += v;
        llSetText(
            "Reading configuration notecard, please wait...\n" + wasSpin(),
            < 1, 1, 0 >,
            1
        );
@continue;
        llGetNotecardLine("configuration", ++line);
    }
    changed(integer change) {
        if (change & CHANGED_INVENTORY || change & CHANGED_OWNER) {
            llResetScript();
        }
    }
    on_rez(integer num) {
        llResetScript();
    }
}
 
state check {
    state_entry() {
        llSetText(
            "Checking for RLV...",
            < 1, 1, 0 >,
            1
        );
        llSetTimerEvent(10);
        llListen(10, "", llGetOwner(), "");
        llOwnerSay("@version=10");
    }
    listen(integer channel, string name, key id, string message) {
        llSetTimerEvent(0);
        llSetText(
            "You are RLV enabled!",
            < 0, 1, 0 >,
            1
        );
        state tip;
    }
    timer() {
        llSetTimerEvent(0);
        llOwnerSay("Your viewer is not RLV-enabled. This gizmo requires a RLV-enabled viewer. Cannot proceed.");
    }
    changed(integer change) {
        if (change & CHANGED_INVENTORY || change & CHANGED_OWNER) {
            llResetScript();
        }
    }
    on_rez(integer num) {
        llResetScript();
    }
}
 
state tip {
    state_entry() {
        llSetText(
            llList2String(
                tuples,
                llListFindList(
                    tuples,
                    (list)"title"
                    ) + 1
                ) + "\n" +
            "Last stripper: " + agent + "\n" +
            "Last payment: " + (string)given + "\n" +
            "Last slot removed: " + item,
            (vector)llList2String(
                tuples,
                llListFindList(
                    tuples,
                    (list)"color"
                    ) + 1
                ),
            1
        );
    }
    touch_start(integer num) {
        client = llDetectedKey(0);
        // If the owner touches, go into the setup state
        if(client == llGetOwner()) state setup;
        integer comChannel = (integer)("0x8" + llGetSubString(client, 0, 6));
        llListen(comChannel, "", client, "");
        llDialog(
            client,
            VERSION + 
            "What type of clothes would you like to strip?",
            [
                "▦ Worn",
                "▣ Attached",
                "⏏ Exit"
            ],
            comChannel
        );
    }
    listen(integer channel, string name, key id, string message) {
        llSetText(
            "In use...",
            < 1, 1, 0 >,
            1
        );
        if (message == "▦ Worn") state get_wearables;
        if (message == "▣ Attached") state get_attachments;
        if (message == "⏏ Exit")  {
            client = NULL_KEY;
            state tip_trampoline;
        }
    }
    changed(integer change) {
        if (change & CHANGED_INVENTORY || change & CHANGED_OWNER) {
            llResetScript();
        }
    }
    on_rez(integer num) {
        llResetScript();
    }
}
 
state tip_trampoline {
    state_entry() {
        state tip;
    }
    changed(integer change) {
        if (change & CHANGED_INVENTORY || change & CHANGED_OWNER) {
            llResetScript();
        }
    }
    on_rez(integer num) {
        llResetScript();
    }
}
 
state setup {
    state_entry() {
        llSetText(
            "Under owner control...",
            < 1, 1, 0 >,
            1
        );
        menu = [];
        integer i = llGetInventoryNumber(INVENTORY_TEXTURE) - 1;
        do {
            menu += llGetInventoryName(INVENTORY_TEXTURE, i);
        } while(--i > -1);
        integer comChannel = (integer)("0x8" + llGetSubString(client, 0, 6));
        llListen(comChannel, "", client, "");
        llDialog(
            client,
            VERSION + 
            "Would you like to strip or configure textures?",
            [
                "▦ Worn",
                "▣ Attached",
                "❤ Textures",
                "⏏ Exit"
            ],
            comChannel
        );
        // alarm 30
        llSetTimerEvent(30);
    }
    listen(integer channel, string name, key id, string message) {
        llSetTimerEvent(30);
        if (message == "⟻ Back") {
            llDialog(
                id,
                VERSION + 
                "Please select from the following available textures:\n", wasDialogMenu(
                    menu,
                    [
                        "⟻ Back",
                        "⏏ Exit",
                        "Next ⟼"
                    ],
                    "<"
                    ),
                channel
            );
            return;
        }
        if (message == "Next ⟼") {
            llDialog(
                id,
                VERSION + 
                "Please select from the following available textures:\n", wasDialogMenu(
                    menu,
                    [
                        "⟻ Back",
                        "⏏ Exit",
                        "Next ⟼"
                    ],
                    ">"
                    ),
                channel
            );
            return;
        }
        if (message == "⏏ Exit") {
            llSetTimerEvent(0);
            client = NULL_KEY;
            state tip;
        }
        if (message == "▦ Worn") state get_wearables;
        if (message == "▣ Attached") state get_attachments;
        if (message == "❤ Textures") jump textures;
        llSetLinkTexture(3, message, ALL_SIDES);
@textures;
        llDialog(
            client,
                VERSION + 
                "Please select from the following available textures:\n",
                wasDialogMenu(
                    menu,
                    [
                        "⟻ Back",
                        "⏏ Exit",
                        "Next ⟼"
                    ],
                    ""
                ),
            channel
        );
    }
    timer() {
        llSetTimerEvent(0);
        client = NULL_KEY;
        state tip;
    }
    changed(integer change) {
        if (change & CHANGED_INVENTORY || change & CHANGED_OWNER) {
            llResetScript();
        }
    }
    on_rez(integer num) {
        llResetScript();
    }
}
 
state get_wearables {
    state_entry() {
        llSetText(
            "Reading wearables, please wait...",
            < 1, 1, 0 >,
            1
        );
        llListen(10, "", llGetOwner(), "");
        llOwnerSay("@getoutfit=10");
    }
    listen(integer channel, string name, key id, string message) {
        menu = WEARABLES;
        integer i = llGetListLength(menu) - 1;
        do {
            if (llListFindList(
                    tuples,
                    llList2List(
                        menu,
                        i,
                        i
                        )
                ) != -1 &&
                (integer)llGetSubString(
                    message,
                    i,
                    i
                ) != FALSE) jump continue;
            menu = llDeleteSubList(menu, i, i);
@continue;
            llSetText(
                "Reading wearables, please wait...\n" + wasSpin(),
                < 1, 1, 0 >,
                1
            );
        } while (--i > -1);
        state strip;
    }
    changed(integer change) {
        if (change & CHANGED_INVENTORY || change & CHANGED_OWNER) {
            llResetScript();
        }
    }
    on_rez(integer num) {
        llResetScript();
    }
}
 
state get_attachments {
    state_entry() {
        llSetText(
            "Reading attachments, please wait...",
            < 1, 1, 0 >,
            1
        );
        llListen(10, "", llGetOwner(), "");
        llOwnerSay("@getattach=10");
    }
    listen(integer channel, string name, key id, string message) {
        menu = ATTACHMENTS;
        integer i = llGetListLength(menu) - 1;
        do {
            if (llListFindList(
                    tuples,
                    llList2List(
                        menu,
                        i,
                        i
                        )
                ) != -1 &&
                (integer)llGetSubString(
                    message,
                    i,
                    i
                ) != FALSE) jump continue;
            menu = llDeleteSubList(menu, i, i);
@continue;
            llSetText(
                "Reading attachments, please wait...\n" + wasSpin(),
                < 1, 1, 0 >,
                1
            );
        } while (--i > -1);
        state strip;
    }
    changed(integer change) {
        if (change & CHANGED_INVENTORY || change & CHANGED_OWNER) {
            llResetScript();
        }
    }
    on_rez(integer num) {
        llResetScript();
    }
}
 
state strip {
    state_entry() {
        llSetText(
            "Selecting item to strip...",
            < 1, 1, 0 >,
            1
        );
        wasMenuIndex = 0;
        integer comChannel = (integer)("0x8" + llGetSubString(client, 0, 6));
        llListen(comChannel, "", client, "");
        llDialog(client,
            VERSION + 
            "Please select the item to remove:\n",
            wasDialogMenu(
                menu,
                [
                    "⟻ Back",
                    "⏏ Exit",
                    "Next ⟼"
                ],
                ""
            ),
            comChannel
        );
        // alarm 30
        llSetTimerEvent(30);
    }
    listen(integer channel, string name, key id, string message) {
        if (message == "⟻ Back") {
            llDialog(
                id,
                VERSION +
                "Please select the item to remove:\n", wasDialogMenu(
                    menu,
                    [
                        "⟻ Back",
                        "⏏ Exit",
                        "Next ⟼"
                    ],
                    "<"
                    ),
                channel
            );
            llSetTimerEvent(30);
            return;
        }
        if (message == "Next ⟼") {
            llDialog(
                id,
                VERSION +
                "Please select the item to remove:\n", wasDialogMenu(
                    menu,
                    [
                        "⟻ Back",
                        "⏏ Exit",
                        "Next ⟼"
                    ],
                    ">"
                    ),
                channel
            );
            llSetTimerEvent(30);
            return;
        }
        if (message == "⏏ Exit") {
            llSetTimerEvent(0);
            client = NULL_KEY;
            state tip;
        }
        integer i = llListFindList(tuples, (list)message);
        if (i != -1) {
            item = llList2String(tuples, i);
            price = llList2Integer(tuples, i + 1);
            llSetPayPrice(price, [ price ]);
            llSetClickAction(CLICK_ACTION_PAY);
            llInstantMessage(
                client,
                "The price for that item is: L$" +
                (string)price +
                ". Please touch the strip jar and pay in order to strip that item."
            );
        }
        llSetText(
            "Waiting for payment...",
            < 1, 1, 0 >,
            1
        );
    }
    money(key id, integer amount) {
        // Stop timer.
        llSetTimerEvent(0);
        // rest == 0 -> exact price
        // rest > 0 -> client paid less
        // rest < 0 -> give back
        integer rest = price - amount;
        // client paid less
        if (rest > 0) {
            llInstantMessage(client, "Sorry, that is not the correct price for that item.");
            llGiveMoney(client, amount);
            jump done;
        }
        // client paid more
        if (rest < 0) {
            llInstantMessage(client, "Thank you! You paid more; here is your change...");
            llGiveMoney(client, llAbs(rest));
        }
        // Show message
        llSetText(
            "Stripping!",
            < 0, 1, 0 >,
            1
        );
        // Save the agent
        agent = llList2String(
            llParseString2List(
                llKey2Name(id),
                [" "],
                []
            ),
            0
        );
        // Save the price
        given = amount;
        // Thanks!
        llInstantMessage(
            client,
            llList2String(
                tuples,
                llListFindList(
                    tuples,
                    (list)"thanks"
                ) + 1
            )
        );
        // Strip wearables.
        if (llListFindList(WEARABLES, (list)item) != -1) {
            llOwnerSay("@remoutfit:" + item + "=force");
            jump done;
        }
        // Strip attachments.
        if (llListFindList(ATTACHMENTS, (list)item) != -1) {
            llOwnerSay("@detach:" + item + "=force");
        }
@done;
        llSetTimerEvent(0);
        client = NULL_KEY;
        // Cancel any outstanding pay price.
        llSetPayPrice(PAY_HIDE, [ PAY_HIDE ]);
        llSetClickAction(CLICK_ACTION_TOUCH);
        state tip;
    }
    timer() {
        llSetTimerEvent(0);
        llInstantMessage(
            client,
            "The strip menu timed out. You can touch the strip jar again to make a selection."
            );
        client = NULL_KEY;
        // Cancel any outstanding pay price.
        llSetPayPrice(PAY_HIDE, [ PAY_HIDE ]);
        llSetClickAction(CLICK_ACTION_TOUCH);
        state tip;
    }
}

secondlife/stripjar/script.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.