User:Allen Kerensky/Myriad Lite/Myriad Lite Module Rumors-Preview6.lsl
From OpenSimulator
< User:Allen Kerensky | Myriad Lite
Revision as of 18:45, 11 August 2012 by Allen Kerensky (Talk | contribs)
Myriad_Lite_Module_Rumor-Preview6.lsl
// Myriad_Lite_Module_Rumors-v0.0.1-20120317.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.1"; // Allen Kerensky's script version string VERSIONDATE = "20120317"; // 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 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(string debugmsg) { if ( FLAG_DEBUG == TRUE ) llSay(DEBUG_CHANNEL,"("+llKey2Name(llGetOwner())+") MOD RUMORS: "+debugmsg); } // SETUP - begin bringing the HUD online SETUP() { FLAG_DEBUG=TRUE; llOwnerSay("Myriad Lite Module Rumors "+VERSION+" "+VERSIONDATE+" starting."); llRegionSay(CHANMYRIAD,"RUMOR_SERVER_FIND"); } // RESET - shut down running animations then reset the script to reload character sheet RESET() { llResetScript(); // now reset } // DEFAULT STATE - load character sheet default { // STATE ENTRY - called on Reset state_entry() { SETUP(); // show credits and start character sheet load } // ON_REZ - logged in with meter, or worn from inventory while running on_rez(integer param) { param = 0; //LSLINT RESET(); // a reset to reload character } // ATTACH - logged in with meter or worn from inventory/ground while running attach(key id) { id = NULL_KEY; // LSLINT RESET(); // a reset to reload character } changed(integer changes) { if ( changes & CHANGED_REGION ) { // moved to another region SETUP(); return; } if ( changes & CHANGED_TELEPORT ) { // moved somewhere - are we in same region? SETUP(); return; } } // 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("Rumor Module Incoming Link Message: "+message); sender = 0; // LSLINT // 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); if ( command == "RUMOR_RESET" ) { RESET(); return; } 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 } // end state running // END