Allen Kerensky"It seems you've been living two lives ..."

Myriad Lite Character Editor

ABANDONED PROTOTYPE replaced with Myriad Lite Character Editor

// Myriad_Lite_Character_Editor-v0.0.0-20131219.lsl
// Copyright (c) 2013 by Allen Kerensky (OSG/SL) All Rights Reserved.
// This work is dual-licensed under
// Creative Commons Attribution (CC BY) 3.0 Unported
// http://creativecommons.org/licenses/by/3.0/
// - or -
// Modified BSD License (3-clause)
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice, 
//   this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
//   this list of conditions and the following disclaimer in the documentation
//   and/or other materials provided with the distribution.
// * Neither the name of Myriad Lite nor the names of its contributors may be
//   used to endorse or promote products derived from this software without
//   specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
// NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// The Myriad RPG System was designed, written, and illustrated by Ashok Desai
// Myriad RPG System licensed under:
// Creative Commons Attribution (CC BY) 2.0 UK: England and Wales
// http://creativecommons.org/licenses/by/2.0/uk/
 
// CONSTANTS - DO NOT CHANGE DURING RUN
string BASENAME = "Myriad Lite Character Editor"; // base name of this script without version or date
string VERSION = "0.0.1"; // Allen Kerensky's script version
string VERSIONDATE = "20131219"; // Allen Kerensky's script yyyymmdd
 
// CONSTANTS
list CATEGORIES = [ "STATISTICS","SKILLS","EFFECTS","RESILIENCES","BOONS","FLAWS","CAMPAIGNS","SPECIES","BACKGROUNDS","CAREERS","ITEMS" ];
 
// RUNTIME GLOBALS
list PRIMNAMES;
integer DYNAMIC_CHANNEL;
integer DYNAMIC_HANDLE;
integer NUMCAT; // number of category in CATEGORIES list
string CURCAT; // name of current category
integer NUMITEM; // number of item in current CATLIST 
string CURITEM; // name of current item in current category list
list CATLIST; // CSV list of items in current category - requested from region setting server
integer RENDEZVOUS1 = -999;
integer HANDLE1;
integer RENDEZVOUS2;
integer HANDLE2;
key WHO; // who is using the setup
integer CHANNEL; // for TextBox popup
integer HANDLE; // for TextBox popup
string REQUEST; // current request to dispatch
 
BUY_ITEM() {
}
 
CLEAR() {
    // put prim number/name pairs into list for UPDATE function to write text on prims
    integer i;
    for (i = 0; i <= llGetNumberOfPrims(); i++) {
        string name = llList2String(llGetLinkPrimitiveParams(i,[PRIM_NAME]),0);
        // if ( llGetSubString(name,0,4) == "SHOW " ) llSetLinkPrimitiveParams(i,[PRIM_TEXT,"",<0,0,0>,0]);
        llSetLinkPrimitiveParams(i,[PRIM_TEXT,"",<0,0,0>,0]);
    }
}
 
COMMAND(string in) {
    REQUEST=in;
    if ( in == "SET_NAME" ) { SET_NAME(); return; }
    if ( in == "SET_NICKNAME" ) { SET_NICKNAME(); return; }
    if ( in == "SET_TITLE" ) { SET_TITLE(); return; }
    if ( in == "SET_FACTION" ) { SET_FACTION(); return; }
    // locate category name from list
    if ( llListFindList(CATEGORIES,[in]) != -1 ) {
        CURCAT = in;
        NUMITEM = 0;
        llRegionSay(RENDEZVOUS2,"LIST_"+CURCAT);
        return;
    }
    if ( in == "PREV ITEM" ) { PREV_ITEM(); return; }
    if ( in == "NEXT ITEM" ) { NEXT_ITEM(); return; }
    if ( in == "BUY ITEM" ) { BUY_ITEM(); return; }
    if ( in == "SELL ITEM" ) { SELL_ITEM(); return; }
    if ( in == "RESET" ) { RESET(); return; }
    if ( in == "SAVE" ) { SAVE(); return; }
}
 
 
NEXT_ITEM() {
    NUMITEM++;
    if ( NUMITEM >= llGetListLength(CATLIST) ) NUMITEM = 0;
    CURITEM = llList2String(CATLIST,NUMITEM);
}
 
PREV_ITEM() {
    NUMITEM--;
    if ( NUMITEM < 0 ) NUMITEM = llGetListLength(CATLIST);
    CURITEM = llList2String(CATLIST,NUMITEM);
}
 
RESET() {
    // do things
    llStopAnimation("turn_180");
    llUnSit(llAvatarOnSitTarget());
    CLEAR();
}
 
SAVE() {
}
 
SELL_ITEM() {
}
 
SET_FACTION() {
    if ( HANDLE == 0 ) {
        CHANNEL = 1+(integer)llFrand(9999.0);
        HANDLE = llListen(CHANNEL,"",NULL_KEY,"");
        llTextBox(llDetectedKey(0),"(Optional) What Is Your Character's Faction?\rYou have 60 seconds to enter a name.",CHANNEL);
        llSetTimerEvent(60.0);
    } else {
        llSay(PUBLIC_CHANNEL,"Tool is already in use, please wait.");
    }
}
 
SET_NAME() {
    if ( HANDLE == 0 ) {
        CHANNEL = 1+(integer)llFrand(9999.0);
        HANDLE = llListen(CHANNEL,"",NULL_KEY,"");
        llTextBox(llDetectedKey(0),"What Is Your Character's First and Last Name?\rYou have 60 seconds to enter a name.",CHANNEL);
        llSetTimerEvent(60.0);
    } else {
        llSay(PUBLIC_CHANNEL,"Tool is already in use, please wait.");
    }
}
 
SET_NICKNAME() {
    if ( HANDLE == 0 ) {
        CHANNEL = 1+(integer)llFrand(9999.0);
        HANDLE = llListen(CHANNEL,"",NULL_KEY,"");
        llTextBox(llDetectedKey(0),"(Optional) What Is Your Character's Nickname?\rYou have 60 seconds to enter a name.",CHANNEL);
        llSetTimerEvent(60.0);
    } else {
        llSay(PUBLIC_CHANNEL,"Tool is already in use, please wait.");
    }
}
 
SET_TITLE() {
    if ( HANDLE == 0 ) {
        CHANNEL = 1+(integer)llFrand(9999.0);
        HANDLE = llListen(CHANNEL,"",NULL_KEY,"");
        llTextBox(llDetectedKey(0),"What Is Your Character's Title?\rExamples: Doctor, Reverend, etc.\rYou have 60 seconds to enter a name.",CHANNEL);
        llSetTimerEvent(60.0);
    } else {
        llSay(PUBLIC_CHANNEL,"Tool is already in use, please wait.");
    }
}
 
SETUP() {
    // llSetText("Myriad Lite Character Editorder (Prototype)\nSit Here To Begin",<1,0,0>,1);
    vector OFFSET = <0,0,1.0>;
    llSitTarget(OFFSET,ZERO_ROTATION);
    llSetSitText("> EDIT <");
 
    // put prim number/name pairs into list for UPDATE function to write text on prims
    integer i;
    for (i = 0; i <= llGetNumberOfPrims(); i++) {
        string name = llList2String(llGetLinkPrimitiveParams(i,[PRIM_NAME]),0);
        PRIMNAMES = PRIMNAMES + [name];
    }
    CLEAR();
 
    // SETUP RENDEZVOUS1 CHANNEL (STATIC) - backward compatible for Preview 6 and earlier
    if ( HANDLE1 != 0 ) llListenRemove(HANDLE1);
    HANDLE1 = llListen(RENDEZVOUS1,"",NULL_KEY,"");
    llSay(PUBLIC_CHANNEL,"Rendezvous1 channel is "+(string)RENDEZVOUS1);
 
    // SETUP RENDEZVOUS2 CHANNEL (DYNAMIC) - new for Preview 7 and later
    list details = llGetParcelDetails(<0,0,0>,[PARCEL_DETAILS_ID]);
    string parcelid = llList2String(details,0);
    RENDEZVOUS2 = (integer)("0x"+llGetSubString(parcelid,0,7));
    if ( HANDLE2 != 0 ) llListenRemove(HANDLE2);
    HANDLE2 = llListen(RENDEZVOUS2,"",NULL_KEY,"");
    llSay(PUBLIC_CHANNEL,"Rendezvous2 channel is "+(string)RENDEZVOUS2);    
 
    // start listener last
    DYNAMIC_CHANNEL = (integer)("0x"+llGetSubString(llGetKey(),0,6));
    if ( DYNAMIC_HANDLE != 0 ) llListenRemove(DYNAMIC_HANDLE);
    DYNAMIC_HANDLE = llListen(DYNAMIC_CHANNEL,"",NULL_KEY,"");
 
    // CURCAT = llList2String(CATEGORIES,NUMCAT);
    // llRegionSay(RENDEZVOUS2,"LIST_"+CURCAT); // request first category
}
 
UPDATE() {
    integer prim = llListFindList(PRIMNAMES,["SHOW CATEGORY"]);
    if ( prim != -1 && CURCAT != "" ) llSetLinkPrimitiveParams(prim,[PRIM_TEXT,CURCAT,<1,1,1>,1.0]);
 
    prim = llListFindList(PRIMNAMES,["SHOW ITEM"]);
    if ( prim != -1 && CURITEM != "" ) llSetLinkPrimitiveParams(prim,[PRIM_TEXT,CURITEM,<1,1,1>,1.0]);
 
    // update item cost
    // update character point pool left
    // update name
    // update faction
    // update species
    // update background
    // update career
}
 
default {
 
    changed(integer change) {
        if ( change & CHANGED_LINK ) { // someone sits or stands up
            WHO = llAvatarOnSitTarget();
            if ( WHO == NULL_KEY ) RESET(); // stood up - reset
            if ( WHO != NULL_KEY ) {
                llRequestPermissions(WHO,PERMISSION_TRIGGER_ANIMATION);
            }
        }
    }
 
    listen(integer channel, string name, key id, string message) {
        if ( channel == CHANNEL ) {
            integer chan = (integer)("0x"+llGetSubString((string)id,0,6));
            if ( REQUEST == "SET_NAME" ) llRegionSay(chan,"SET_NAME|NAME="+message);
            if ( REQUEST == "SET_NICKNAME" ) llRegionSay(chan,"SET_NICKNAME|NICKNAME="+message);
            if ( REQUEST == "SET_TITLE" ) llRegionSay(chan,"SET_TITLE|TITLE="+message);
            if ( REQUEST == "SET_FACTION" ) llRegionSay(chan,"SET_FACTION|FACTION="+message);
            if ( HANDLE != 0 ) llListenRemove(HANDLE);
            llSetTimerEvent(0.0);
            HANDLE = 0;
            return;
        }
 
        string prefix = llList2String( llParseString2List(message,["|"],[]) ,0); // get the field before the first |
        if ( llListFindList(CATEGORIES,[prefix]) ) { // if that field is a category name, this is a reply to a LIST_ request
            CATLIST = llCSV2List( llList2String( llParseString2List(message,["|"],[]) ,1) ); // get the CSV list from response
            CURITEM = llList2String(CATLIST,NUMITEM);
            UPDATE();
            return;
        }
    }
 
    run_time_permissions(integer perm) {
        if ( perm & PERMISSION_TRIGGER_ANIMATION ) llStartAnimation("turn_180");
    }
 
    state_entry() {
        SETUP();
    }
 
    timer() {
        if ( HANDLE != 0 ) llListenRemove(HANDLE);
        llSay(PUBLIC_CHANNEL,"Time expired. Please try again when ready.");
        HANDLE = 0;
    }
 
    touch_start(integer num_detected) {
        if ( WHO == NULL_KEY) return; // if no one on sit target, ignore clicks
        string action = llGetLinkName(llDetectedLinkNumber(0)); // get name of prim clicked in link set
        if ( action != "" && action != llGetObjectName() ) { // someone clicked a named button prim on this linkset
            COMMAND(action); // try that prim name as a command
            return;
        }
    }    
}
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
DokuWiki