glamour_heels_right.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    //
///////////////////////////////////////////////////////////////////////////
vector wasStringToVector(string in) {
    list v = llParseString2List(in, ["<", ",", ">"], []);
    return <llList2Float(v, 0), llList2Float(v, 1), llList2Float(v, 2)>;
}
 
///////////////////////////////////////////////////////////////////////////
//    Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3    //
///////////////////////////////////////////////////////////////////////////
vector wasRGBToColor(vector rgb) {
    return <rgb.x / 255, rgb.y / 255, rgb.z / 255>;
}
 
///////////////////////////////////////////////////////////////////////////
//    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, "&");
}
 
///////////////////////////////////////////////////////////////////////////
//    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 "";
}
 
integer switch = 0;
 
default {
    state_entry() {
        if(switch == 0) return;
        switch = 0;
        integer channel = (integer)("0x8" + llGetSubString(llGetOwner(), 0, 6));
        llListen(channel, "", llGetOwner(), "");
        llDialog(llGetOwner(), "\n            Welcome to the Glamour Heels.\nCreated in 2013 by Wizardry and Steamworks\n                 18 Jun 2013: Version: 1.0", [ "☀ Skin", "☂ Heel", "❖ Nails", "☊ Ring", "↔ Resize", "✖ Commit" ], channel);
    }
    touch_start(integer num) {
        if(llDetectedKey(0) != llGetOwner()) return;
        integer channel = (integer)("0x8" + llGetSubString(llGetOwner(), 0, 6));
        llListen(channel, "", llGetOwner(), "");
        llDialog(llGetOwner(), "\n            Welcome to the Glamour Heels.\nCreated in 2013 by Wizardry and Steamworks\n                 18 Jun 2013: Version: 1.0", [ "☀ Skin", "☂ Heel", "❖ Nails", "☊ Ring", "↔ Resize", "✖ Commit" ], channel);
    }
    listen(integer channel, string name, key owner, string message) {
        if(message == "☀ Skin") state skin_adjust;
        if(message == "☂ Heel") state heel_adjust;
        if(message == "❖ Nails") state nail_adjust;
        if(message == "☊ Ring") state ring_adjust;
        if(message == "↔ Resize") state tandem_resize;
        if(message == "✖ Commit") {
            llDialog(owner, "\n            Welcome to the Glamour Heels.\nCreated in 2013 by Wizardry and Steamworks\n                 18 Jun 2013: Version: 1.0\n\nThis option will delete the script and make your configuration permanent. This is meant to keep your script consumption down and to please those that believe that scripts are the principal source of lag. After pressing the DELETE button below, this script will delete itself and you will not be able to reconfigure your shoes.", ["DELETE", "CANCEL"], channel);
            return;
        }
        if(message == "DELETE") {
            llWhisper(channel, "modify=delete");
            llRemoveInventory(llGetScriptName());
        }
    }
    on_rez(integer param) {
        llResetScript();
    }
}
 
state skin_adjust {
    state_entry() {
        integer channel = (integer)("0x8" + llGetSubString(llGetOwner(), 0, 6));
        llListen(channel, "", llGetOwner(), "");
        llDialog(llGetOwner(), "\n            Welcome to the Glamour Heels.\nCreated in 2013 by Wizardry and Steamworks\n                 18 Jun 2013: Version: 1.0", ["✯ Color", "✰ Tone", "⏏ Exit"], channel);
    }
    touch_start(integer num) {
        if(llDetectedKey(0) != llGetOwner()) return;
        integer channel = (integer)("0x8" + llGetSubString(llGetOwner(), 0, 6));
        llListen(channel, "", llGetOwner(), "");
        llDialog(llGetOwner(), "\n            Welcome to the Glamour Heels.\nCreated in 2013 by Wizardry and Steamworks\n                 18 Jun 2013: Version: 1.0", ["✯ Color", "✰ Tone", "⏏ Exit"], channel);
    }
    listen(integer channel, string name, key owner, string message) {
        if(message == "⏏ Exit") {
            switch = 1;
            state default;
        }
        if(message == "⟵ Back") {
            llDialog(llGetOwner(), "\n            Welcome to the Glamour Heels.\nCreated in 2013 by Wizardry and Steamworks\n                 18 Jun 2013: Version: 1.0", ["✯ Color", "✰ Tone", "⏏ Exit"], channel);
            return;
        }
        if(message == "✰ Tone") {
            llDialog(llGetOwner(), "\n            Welcome to the Glamour Heels.\nCreated in 2013 by Wizardry and Steamworks\n                 18 Jun 2013: Version: 1.0", ["Dark -", "Light +", "⟵ Back"], channel);
            return;
        }
        if(message == "✯ Color") {
            llTextBox(llGetOwner(), "\n            Welcome to the Glamour Heels.\nCreated in 2013 by Wizardry and Steamworks\n                 18 Jun 2013: Version: 1.0\n\n            Please specify a color vector.\n              Format: <red,green,blue>", channel);
            return;
        }
        vector color = wasRGBToColor(wasStringToVector(message));
        if(message != "Dark -" && message != "Light +") jump commit;
        color = llList2Vector(llGetLinkPrimitiveParams(2, [PRIM_COLOR, ALL_SIDES]), 0);
        float m = (float) ( llGetSubString(message, -1, -1) + ".01" );
        color = <color.x+m,color.y+m,color.z+m>;
        llDialog(owner, "\n            Welcome to the Glamour Heels.\nCreated in 2013 by Wizardry and Steamworks\n                 18 Jun 2013: Version: 1.0", ["Dark -", "Light +", "⟵ Back"], channel);
@commit;
        llWhisper(channel, "modify=skin&color=" + (string)color);
        list skin = [ 2, 20, 17, 19, 10, 13 ];
        integer i = llGetListLength(skin)-1;
        do {
            llSetLinkPrimitiveParamsFast(llList2Integer(skin,i), [PRIM_COLOR, ALL_SIDES, color, 1.0]);
        } while(--i>-1);
    }
    on_rez(integer param) {
        llResetScript();
    }
}
 
state heel_adjust {
    state_entry() {
        integer channel = (integer)("0x8" + llGetSubString(llGetOwner(), 0, 6));
        llListen(channel, "", llGetOwner(), "");
        llDialog(llGetOwner(), "\n            Welcome to the Glamour Heels.\nCreated in 2013 by Wizardry and Steamworks\n                 18 Jun 2013: Version: 1.0", ["␥ Straps", "⎲ Strut", "⏏ Exit"], channel);
    }
    touch_start(integer num) {
        if(llDetectedKey(0) != llGetOwner()) return;
        integer channel = (integer)("0x8" + llGetSubString(llGetOwner(), 0, 6));
        llListen(channel, "", llGetOwner(), "");
        llDialog(llGetOwner(), "\n            Welcome to the Glamour Heels.\nCreated in 2013 by Wizardry and Steamworks\n                 18 Jun 2013: Version: 1.0", ["␥ Straps", "⎲ Strut", "⏏ Exit"], channel);
    }
    listen(integer channel, string name, key owner, string message) {
        if(message == "⏏ Exit") {
            switch = 1;
            state default;
        }
        if(message == "␥ Straps") {
            llSetObjectDesc(wasKeyValueSet("heel", "straps", llGetObjectDesc()));
            jump coloring;
        }
        if(message == "⎲ Strut") {
            llSetObjectDesc(wasKeyValueSet("heel", "strut", llGetObjectDesc()));
            jump coloring;
        }
        vector color = wasRGBToColor(wasStringToVector(message));
        if(wasKeyValueGet("heel", llGetObjectDesc()) != "straps") jump struts;
        llWhisper(channel, "modify=strap&color=" + (string)color);
        list straps = [ 14, 8, 9 ];
        integer i = llGetListLength(straps)-1;
        do {
            llSetLinkPrimitiveParamsFast(llList2Integer(straps,i), [PRIM_COLOR, ALL_SIDES, color, 1.0]);
        } while(--i>-1);
        return;
@struts;
        if(wasKeyValueGet("heel", llGetObjectDesc()) != "strut") jump coloring;
        llWhisper(channel, "modify=heel&color=" + (string)color);
        llSetLinkPrimitiveParamsFast(4, [PRIM_COLOR, ALL_SIDES, color, 1.0]);
        return;
@coloring;
        llTextBox(owner, "\n            Welcome to the Glamour Heels.\nCreated in 2013 by Wizardry and Steamworks\n                 18 Jun 2013: Version: 1.0\n\n            Please specify a color vector.\n              Format: <red,green,blue>", channel);
    }
    on_rez(integer param) {
        llResetScript();
    }
}
 
state nail_adjust {
    state_entry() {
        integer channel = (integer)("0x8" + llGetSubString(llGetOwner(), 0, 6));
        llListen(channel, "", llGetOwner(), "");
        llDialog(llGetOwner(), "\n            Welcome to the Glamour Heels.\nCreated in 2013 by Wizardry and Steamworks\n                 18 Jun 2013: Version: 1.0", ["⌞ Left", "Right ⌟", "⏏ Exit"], channel);
    }
    touch_start(integer total_number) {
        if(llDetectedKey(0) != llGetOwner()) return;
        integer channel = (integer)("0x8" + llGetSubString(llGetOwner(), 0, 6));
        llListen(channel, "", llGetOwner(), "");
        llDialog(llGetOwner(), "\n            Welcome to the Glamour Heels.\nCreated in 2013 by Wizardry and Steamworks\n                 18 Jun 2013: Version: 1.0", ["⌞ Left", "Right ⌟", "⏏ Exit"], channel);
    }
    listen(integer channel, string name, key owner, string message) {
        if(message == "⏏ Exit") {
            switch = 1;
            state default;
        }
        if(message != "⌞ Left" && message != "Right ⌟") jump numbers;
        if(message == "Right ⌟") llSetObjectDesc(wasKeyValueSet("foot", "right", llGetObjectDesc()));
        if(message == "⌞ Left") llSetObjectDesc(wasKeyValueSet("foot", "left", llGetObjectDesc()));
        llDialog(owner, "\n            Welcome to the Glamour Heels.\nCreated in 2013 by Wizardry and Steamworks\n                 18 Jun 2013: Version: 1.0\n\n              Please specify a toe number.", ["1", "2", "3", "4", "5", "⏏ Exit"], channel);
        return;
@numbers;
        if((integer)message == 0) jump colors;
        llSetObjectDesc(wasKeyValueSet("phalange", message, llGetObjectDesc()));
        llTextBox(owner, "\n            Welcome to the Glamour Heels.\nCreated in 2013 by Wizardry and Steamworks\n                 18 Jun 2013: Version: 1.0\n\n            Please specify a color vector.\n              Format: <red,green,blue>", channel);
        return;
@colors;
        vector color = wasRGBToColor(wasStringToVector(message));
        if(wasKeyValueGet("foot", llGetObjectDesc()) != "right") {
            llWhisper(channel, "modify=pedicure&phalange=" + wasKeyValueGet("phalange", llGetObjectDesc()) + "&color=" + (string)color);
            jump phalanges;
        }
        list nails = [ 21, 16, 12, 15, 11 ];
        llSetLinkPrimitiveParamsFast(llList2Integer(nails,(integer)wasKeyValueGet("phalange", llGetObjectDesc())-1), [PRIM_COLOR, ALL_SIDES, color, 1.0]);
@phalanges;
        llDialog(owner, "\n            Welcome to the Glamour Heels.\nCreated in 2013 by Wizardry and Steamworks\n                 18 Jun 2013: Version: 1.0\n\n              Please specify a toe number.", ["1", "2", "3", "4", "5", "⏏ Exit"], channel);
    }
    on_rez(integer param) {
        llResetScript();
    }
}
 
state ring_adjust {
    state_entry() {
        integer channel = (integer)("0x8" + llGetSubString(llGetOwner(), 0, 6));
        llListen(channel, "", llGetOwner(), "");
        llDialog(llGetOwner(), "\n            Welcome to the Glamour Heels.\nCreated in 2013 by Wizardry and Steamworks\n                 18 Jun 2013: Version: 1.0", [ "➊", "➋", "➌", "➍", "➎", "➏", "➐", "➑", "⏏ Exit" ], channel);
    }
    touch_start(integer total_number) {
        if(llDetectedKey(0) != llGetOwner()) return;
        integer channel = (integer)("0x8" + llGetSubString(llGetOwner(), 0, 6));
        llListen(channel, "", llGetOwner(), "");
        llDialog(llGetOwner(), "\n            Welcome to the Glamour Heels.\nCreated in 2013 by Wizardry and Steamworks\n                 18 Jun 2013: Version: 1.0", [ "➊", "➋", "➌", "➍", "➎", "➏", "➐", "➑", "⏏ Exit" ], channel);
    }
    listen(integer channel, string name, key owner, string message) {
        if(message == "⏏ Exit") {
            switch = 1;
            state default;
        }
        llSetLinkTexture(7, llList2Key([
            "4743b21e-228a-fe9e-5e47-cfc520aaa93c",
            "b3455767-bf73-ad62-643f-41e0c6d02e05",
            "39ba3d80-4711-8628-b0da-bc1cc576e468",
            "f5e6b07e-eb76-d730-5c8d-8c9cc59b61d5",
            "7d62435f-d153-a65a-a547-b7b1e2253695",
            "d45a74e8-957e-9f41-114c-48ece079d5f5",
            "a5a8426d-b095-0e86-7e6f-550a0161b066",
            "840b002a-c0d8-ba8b-fc06-0733a070cbc8"
        ],llListFindList([ "➊", "➋", "➌", "➍", "➎", "➏", "➐", "➑" ], (list)message)), 0);
        llDialog(owner, "\n            Welcome to the Glamour Heels.\nCreated in 2013 by Wizardry and Steamworks\n                 18 Jun 2013: Version: 1.0", [ "➊", "➋", "➌", "➍", "➎", "➏", "➐", "➑", "⏏ Exit" ], channel);
    }
    on_rez(integer param) {
        llResetScript();
    }
}
 
state tandem_resize {
    state_entry() {
        integer channel = (integer)("0x8" + llGetSubString(llGetOwner(), 0, 6));
        llListen(channel, "", llGetOwner(), "");
        llDialog(llGetOwner(), "\n            Welcome to the Glamour Heels.\nCreated in 2013 by Wizardry and Steamworks\n                 18 Jun 2013: Version: 1.0", ["-.01", "-.02", "-.05", "+.01", "+.02", "+.05", "⏏ Exit"], channel);
    }
    touch_start(integer num) {
        if(llDetectedKey(0) != llGetOwner()) return;
        integer channel = (integer)("0x8" + llGetSubString(llGetOwner(), 0, 6));
        llListen(channel, "", llGetOwner(), "");
        llDialog(llGetOwner(), "\n            Welcome to the Glamour Heels.\nCreated in 2013 by Wizardry and Steamworks\n                 18 Jun 2013: Version: 1.0", ["-.01", "-.02", "-.05", "+.01", "+.02", "+.05", "⏏ Exit"], channel);
    }
    listen(integer channel, string name, key owner, string message) {
        if(message == "⏏ Exit") {
            switch = 1;
            state default;
        }
        if((float)message == 0) return;
        float scale = 1 + (float)message;
        llWhisper(channel, "modify=size&scale=" + (string)scale);
        integer i = llGetNumberOfPrims();
        do {
            vector linkScale = llList2Vector(llGetLinkPrimitiveParams(i, [PRIM_SIZE]), 0);
            vector linkPos = llList2Vector(llGetLinkPrimitiveParams(i, [PRIM_POS_LOCAL]), 0);
            llSetLinkPrimitiveParamsFast(i, [PRIM_SIZE, scale * linkScale, PRIM_POSITION, scale * linkPos]);
        } while(--i>1);
        llDialog(owner, "\n            Welcome to the Glamour Heels.\nCreated in 2013 by Wizardry and Steamworks\n                 18 Jun 2013: Version: 1.0", ["-.01", "-.02", "-.05", "+.01", "+.02", "+.05", "⏏ Exit"], channel);
    }
    on_rez(integer num) {
        llResetScript();
    }
}