glamour_heels_left_relay.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    //
///////////////////////////////////////////////////////////////////////////
vector wasStringToVector(string in) {
    list v = llParseString2List(in, ["<", ",", ">"], []);
    return <llList2Float(v, 0), llList2Float(v, 1), llList2Float(v, 2)>;
}
 
default {
    state_entry() {
        integer channel = (integer)("0x8" + llGetSubString(llGetOwner(), 0, 6));
        llListen(channel, "", "", "");
    }
    listen(integer channel, string name, key toucher, string message) {
        if(llGetOwner() != llGetOwnerKey(toucher) || toucher == llGetOwner()) return;
        if(wasKeyValueGet("modify", message) != "delete") jump region_resize;
        llRemoveInventory(llGetScriptName());
        return;
@region_resize;
        integer i;
        if(wasKeyValueGet("modify", message) != "size") jump region_pedicure;
        float scale = (float)wasKeyValueGet("scale", message);
        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);
        return;
@region_pedicure;
        vector color = wasStringToVector(wasKeyValueGet("color", message));
        if(wasKeyValueGet("modify", message) != "pedicure") jump region_strap;
        integer phalange = (integer)wasKeyValueGet("phalange", message)-1;
        list nails = [ 4, 11, 14, 17, 19 ];
        llSetLinkPrimitiveParamsFast(llList2Integer(nails,phalange), [PRIM_COLOR, ALL_SIDES, color, 1.0]);
        return;
@region_strap;
        if(wasKeyValueGet("modify", message) != "strap") jump region_strut;
        list strap = [ 15, 12, 7 ];
        i = llGetListLength(strap)-1;
        do {
            llSetLinkPrimitiveParamsFast(llList2Integer(strap,i), [PRIM_COLOR, ALL_SIDES, color, 1.0]);
        } while(--i>-1);
        return;
@region_strut;
        if(wasKeyValueGet("modify", message) != "heel") jump region_skin;
        llSetLinkPrimitiveParamsFast(8, [PRIM_COLOR, ALL_SIDES, color, 1.0]);
        return;
@region_skin;
        if(wasKeyValueGet("modify", message) != "skin") return;
        list skin = [ 21, 3, 9, 13, 16, 18 ];
        i = llGetListLength(skin)-1;
        do {
            llSetLinkPrimitiveParamsFast(llList2Integer(skin,i), [PRIM_COLOR, ALL_SIDES, color, 1.0]);
        } while(--i>-1);
    }
    on_rez(integer param) {
        llResetScript();
    }
}