User:Allen Kerensky/Myriad Lite/Myriad Lite Module Rumors-v0.0.2-20120826.lsl

From OpenSimulator

Jump to: navigation, search

Myriad_Lite_Module_Rumors-v0.0.2-20120826.lsl

// Myriad_Lite_Module_Rumors-v0.0.2-20120826.lsl 
// Copyright (c) 2012 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 VERSION = "0.0.2"; // Allen Kerensky's script version
string VERDATE = "20120826"; // Allen Kerensky's script yyyymmdd
// Module to Module Messaging Constants
// integer MODULE_HUD = -1;
// integer MODULE_CHARSHEET = -2;
// integer MODULE_ARMOR = -3;
// integer MODULE_BAM = -4;
integer MODULE_RUMORS = -5; // Which Module Link Message number do I listen for?
// integer MODULE_CLOSE = -6;
// integer MODULE_RANGED = -7;
// integer MODULE_RESILIENCE = -8;
// integer MODULE_PROGRESS = -9;
// integer MODULE_WELL = -10;
// integer MODULE_METER = -11;
integer LM_SENDTOATTACHMENT = 0x80000000;
 
integer CHANMYRIAD = -999; // regionwide rendezvous channel
string CHAN_PREFIX = "0x"; // channel prefix for calculating dynamic channels
string DIV = "|"; // message field divider
 
// RUNTIME GLOBALS - CAN CHANGE DURING RUN
integer CHANOBJ; // channel of thing we're talking to
string RUMOR; // the current rumor we've heard
integer FLAG_DEBUG; // configure in SETUP function, LSLINT hack
 
// DEBUG
DEBUG(string debugmsg) {
    if ( FLAG_DEBUG == TRUE ) llSay(DEBUG_CHANNEL,"("+llKey2Name(llGetOwner())+") MOD RUMORS: "+debugmsg);
}
 
// GETVERSION
GETVERSION() {
    SENDTOHUD("VERSION="+VERSION+DIV+"VERSIONDATE="+VERDATE+DIV+llGetObjectName());
}
 
// RESET - shut down running animations then reset the script to reload character sheet
RESET() {
    llResetScript(); // now reset
}
 
// SENDTOHUD - send reponses to HUD as Link Messages
SENDTOHUD(string str) {
    DEBUG("SENDTOHUD("+str+")");
    llMessageLinked(LINK_THIS,LM_SENDTOATTACHMENT,str,llGetOwner());    
}
 
// SETUP - begin bringing the HUD online
SETUP() {
    FLAG_DEBUG=FALSE;
    llRegionSay(CHANMYRIAD,"RUMOR_SERVER_FIND");
}
 
// DEFAULT STATE - load character sheet
default {
 
    // LINK MESSAGE - commands to and from other prims in HUD
    link_message(integer sender,integer sending_module,string message, key speakerid) {
        if ( sending_module == MODULE_RUMORS || sending_module == LM_SENDTOATTACHMENT ) return; // ignore our own link messages
        DEBUG("EVENT: link_message("+(string)sender+","+(string)sending_module+","+message+","+(string)speakerid+")");
 
        // break down the commands and messages into units we can work with
        list fields = llParseString2List(message,[DIV],[]); // break into list of fields based on DIVider
        string command = llList2String(fields,0); // assume the first field is a Myriad Lite command
        //string data1   = llList2String(fields,1);
        //string data2   = llList2String(fields,2);
        //string data3   = llList2String(fields,3);
 
        // General Myriad Module Commnads
        if ( command == "DEBUGOFF" ) { FLAG_DEBUG = FALSE; return;} // disable debugging
        if ( command == "DEBUGON" ) { FLAG_DEBUG = TRUE; return;} // enable debugging
        if ( command == "RESET" ) { RESET(); return;} // reset when told
        if ( command == "VERSION" ) { GETVERSION(); return;} // get version when needed
 
        if ( command == "RUMOR_SERVER_FIND" ) {
            llRegionSay(CHANMYRIAD,"RUMOR_FIND_SERVER");
            return;
        }
        if ( command == "RUMOR_SERVER_FOUND" ) {
            // calculate dynamic channel of item/player talking to us
            CHANOBJ = (integer)(CHAN_PREFIX + llGetSubString((string)speakerid,0,6));
            llOwnerSay("This region supports Myriad Lite rumors.");
            return;
        }
        if ( command == "RUMOR_GET" ) { // does player want to get a rumor from system?
            llRegionSay(CHANOBJ,"RUMOR_GET|"+(string)llGetKey());
            return;
        }
        if ( command == "RUMOR_SHOW" ) { // incoming rumor from the system
            RUMOR = "";
            RUMOR = llGetSubString(message,llSubStringIndex(message,DIV),-1);
            llOwnerSay("You hear a rumor, \""+RUMOR+"\"");
            return;
        }
        if ( command == "RUMOR_MAIN" ) { // ask for rumor main menu (admins only)
            llRegionSay(CHANOBJ,"RUMOR_MAIN" );
            return;
        }
        if ( command == "RUMOR_MODERATE" ) { // ask for first rumor to moderate (admins only)
            llRegionSay(CHANOBJ,"RUMOR_MODERATE" );
            return;
        }
        if ( command == "RUMOR_YES" ) { // approve rumor (for admins only)
            llRegionSay(CHANOBJ,"RUMOR_LIST" );
            return;
        }
        if ( command == "RUMOR_LIST" ) { // ask for list of all rumors in system (for admins only)
            llRegionSay(CHANOBJ,"RUMOR_LIST" );
            return;
        }
        if ( command == "RUMOR_PENDING" ) { // ask for next pending rumor
            llRegionSay(CHANOBJ,"RUMOR_PENDING");
            return;
        }
        if ( command == "RUMOR_NONE_PENDING" ) { // none left
            llOwnerSay("No rumors pending");
        }
        if ( command == "RUMOR_APPROVE" ) { // approve a pending rumor (for admins only)
            llRegionSay(CHANOBJ,"RUMOR_APPROVE");
            return;
        }
        if ( command == "RUMOR_APPROVED" ) { // confirmed
            llOwnerSay("Rumor approved.");
            return;
        }
        if ( command == "RUMOR_REMOVE" ) { // remove a pending
            llRegionSay(CHANOBJ,"RUMOR_REMOVE");
            return;
        }
        if ( command == "RUMOR_REMOVED" ) { // confirmed
            llOwnerSay("Rumor Removed");
            return;
        }
        if ( command == "RUMOR_PUT" ) { // does player want to put a rumor into system?
            llRegionSay(CHANOBJ,"RUMOR_PUT|"+llKey2Name(llGetOwner())+"|"+llList2String(fields,1));
            return;
        }
    } // end listen
 
    // STATE ENTRY - called on Reset
    state_entry() {
        SETUP(); // show credits and start character sheet load
    }
} // end state running
// END
Personal tools
General
About This Wiki