User:Allen Kerensky/Myriad Lite Dev/Myriad Lite Module Rumors-v0.0.1-20120317.lsl
From OpenSimulator
< User:Allen Kerensky | Myriad Lite Dev
Revision as of 19:14, 17 March 2012 by Allen Kerensky (Talk | contribs)
Myriad_Lite_Module_Rumors-v0.0.1-20120317.lsl
// Myriad_Lite_Module_Rumors-v0.0.1-20120317.lsl // The Myriad RPG System was designed, written, and illustrated by Ashok Desai // Myriad RPG licensed under the Creative Commons Attribution 2.0 UK: England and Wales // http://creativecommons.org/licenses/by/2.0/uk/ // Myriad Lite software Copyright (c) 2011 by Allen Kerensky (OSG/SL) // Myriad Lite Module Rumors licensed under the // Creative Commons Attribution-Share Alike-Non-Commercial 3.0 Unported // http://creativecommons.org/licenses/by-nc-sa/3.0/ // 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=FALSE; 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|"+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