User:Allen Kerensky/Myriad Lite Dev/Myriad Lite Module WELL-v0.0.2-20120626.lsl
From OpenSimulator
< User:Allen Kerensky | Myriad Lite Dev
Revision as of 13:43, 26 June 2012 by Allen Kerensky (Talk | contribs)
Myriad_Lite_Module_WELL-v0.0.2-20120626.lsl
// Myriad_Lite_Module_WELL-v0.0.2-20120626.lsl // Copyright (c) 2012 By Allen Kerensky (OSG/SL) // 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-2012 by Allen Kerensky (OSG/SL) // Baroun's Adventure Machine Copyright (c) 2008-2011 by Baroun Tardis (SL) // Myriad Lite and Baroun's Adventure Machine licensed under the // Creative Commons Attribution-Share Alike-Non-Commercial 3.0 Unported // http://creativecommons.org/licenses/by-nc-sa/3.0/ // You must agree to the terms of this license before making any use of this software. // If you do not agree to this license, simply delete these materials. // There is no warranty, express or implied, for your use of these materials. // CONSTANTS - DO NOT CHANGE DURING RUN string VERSION = "0.0.2"; // Allen Kerensky's script version string VERSIONDATE = "20120626"; // Allen Kerensky's script yyyymmdd integer MODULE_WELL = -10; // some random integer constant integer FLAG_DEBUG; // TRUE = output debug messages, FALSE = hide them, set in STATE_ENTRY for lslint // Particle system presets // name, length of list for name, list of rules data ready to pass to llParticleSystem list PRESETS = [ "Ruth2", 39, PSYS_PART_FLAGS, 0, // color interp true, glow true, size interp true, followsrc true, followtarget true PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_ANGLE_CONE, PSYS_SRC_INNERANGLE, PI, PSYS_SRC_OUTERANGLE, 0.0, PSYS_PART_START_SCALE, <.8,1,1>, PSYS_PART_END_SCALE, <0.02, 0.02, 0.02>, PSYS_PART_START_ALPHA, 1.0, PSYS_PART_END_ALPHA, 0.0, PSYS_PART_START_COLOR, <1,1,1>, PSYS_PART_END_COLOR, <1,1,1>, PSYS_PART_MAX_AGE, 3.0, PSYS_SRC_MAX_AGE, 0.0, PSYS_SRC_BURST_RATE, 0.020, PSYS_SRC_BURST_PART_COUNT, 1, PSYS_SRC_BURST_RADIUS, 1.0, PSYS_SRC_BURST_SPEED_MAX, 1, PSYS_SRC_BURST_SPEED_MIN, .1, PSYS_SRC_TEXTURE, "e50ed3cf-6fab-4afe-ac37-187a7d7ab0b8", // ruth cloud particle PSYS_SRC_OMEGA, <0,0,0>, PSYS_SRC_ACCEL, <0,0,0> ]; DEBUG(string debugmsg) { if ( FLAG_DEBUG == TRUE ) llSay(DEBUG_CHANNEL,"("+llKey2Name(llGetOwner())+") MODULE_OUTPUT DEBUG: "+debugmsg); } ERROR(string errmsg) { llSay(DEBUG_CHANNEL,"("+llKey2Name(llGetOwner())+") MODULE_OUTPUT ERROR: "+errmsg); } RESET() { // do any final work here // then reset llResetScript(); } SETUP() { FLAG_DEBUG=TRUE; llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION); } //============================================================================ //============================================================================ default { //------------------------------------------------------------------------ //------------------------------------------------------------------------ attach(key id) { DEBUG("Attached to "+llKey2Name(id)+" ("+(string)id+") Resetting."); RESET(); } //------------------------------------------------------------------------ //------------------------------------------------------------------------ changed(integer change) { if ( change & CHANGED_REGION ) { DEBUG("Region Change detected. Resetting to known state."); RESET(); } if ( change & CHANGED_TELEPORT ) { DEBUG("Teleport detected. Resetting to known state."); RESET(); } } //------------------------------------------------------------------------ //------------------------------------------------------------------------ link_message(integer sender_num,integer num,string str,key id) { if ( num == MODULE_WELL ) return; // ignore our own link messages DEBUG("link_message("+(string)sender_num+","+(string)num+","+str+","+(string)id+")"); // Break down incoming command list tokens = llParseString2List(str,["|"],[]); integer fields = llGetListLength(tokens); string cmd = llToLower(llStringTrim(llList2String(tokens,0),STRING_TRIM)); // DEBUGOFF if ( cmd == "debugoff" ) { DEBUG("Turning off DEBUG messages."); FLAG_DEBUG = FALSE; return; } // DEBUGON if ( cmd == "debugon" ) { FLAG_DEBUG = TRUE; DEBUG("Turning on DEBUG messages."); return; } // DEBUG|debugmessage... if ( cmd == "debug" ) { DEBUG(llList2String(tokens,1)); return; } // ERROR|errormessage... if ( cmd == "error" ) { ERROR(llList2String(tokens,1)); return; } // OWNERSAY|errormessage... if ( cmd == "ownersay" ) { llOwnerSay(llList2String(tokens,1)); return; } // WHISPER|CHANNEL=###|MESSAGE=... if ( cmd == "whisper" ) { integer channel = DEBUG_CHANNEL; string message = ""; while ( fields-- ) { string attrib = llToLower(llList2String(llParseString2List(llList2String(tokens,fields),["="],[]),0)); if ( attrib == "channel" ) channel = llList2Integer(llParseString2List(llList2String(tokens,fields),["="],[]),1); if ( attrib == "message" ) message = llList2String(llParseString2List(llList2String(tokens,fields),["="],[]),1); } if ( channel != DEBUG_CHANNEL && message != "" ) { llWhisper(channel,message); } else { ERROR("Invalid WHISPER Command Received"); } return; } // SAY|CHANNEL=###|MESSAGE=... if ( cmd == "say" ) { integer channel = DEBUG_CHANNEL; string message = ""; while ( fields-- ) { string attrib = llToLower(llList2String(llParseString2List(llList2String(tokens,fields),["="],[]),0)); if ( attrib == "channel" ) channel = llList2Integer(llParseString2List(llList2String(tokens,fields),["="],[]),1); if ( attrib == "message" ) message = llList2String(llParseString2List(llList2String(tokens,fields),["="],[]),1); } if ( channel != DEBUG_CHANNEL && message != "" ) { llSay(channel,message); } else { ERROR("Invalid SAY Command Received"); } return; } // SHOUT|CHANNEL=###|MESSAGE=... if ( cmd == "shout" ) { integer channel = DEBUG_CHANNEL; string message = ""; while ( fields-- ) { string attrib = llToLower(llList2String(llParseString2List(llList2String(tokens,fields),["="],[]),0)); if ( attrib == "channel" ) channel = llList2Integer(llParseString2List(llList2String(tokens,fields),["="],[]),1); if ( attrib == "message" ) message = llList2String(llParseString2List(llList2String(tokens,fields),["="],[]),1); } if ( channel != DEBUG_CHANNEL && message != "" ) { llShout(channel,message); } else { ERROR("Invalid SHOUT Command Received"); } return; } // REGIONSAY|CHANNEL=###|MESSAGE=... if ( cmd == "regionsay" ) { integer channel = DEBUG_CHANNEL; string message = ""; while ( fields-- ) { string attrib = llToLower(llList2String(llParseString2List(llList2String(tokens,fields),["="],[]),0)); if ( attrib == "channel" ) channel = llList2Integer(llParseString2List(llList2String(tokens,fields),["="],[]),1); if ( attrib == "message" ) message = llList2String(llParseString2List(llList2String(tokens,fields),["="],[]),1); } if ( channel != DEBUG_CHANNEL && message != "" ) { llRegionSay(channel,message); } else { ERROR("Invalid REGIONSAY Command Received"); } return; } // INSTANTMESSAGE|USER=uuid|MESSAGE=... if ( cmd == "instantmessage" ) { key user = NULL_KEY; string message = ""; while ( fields-- ) { string attrib = llToLower(llList2String(llParseString2List(llList2String(tokens,fields),["="],[]),0)); if ( attrib == "user" ) user = llList2Key(llParseString2List(llList2String(tokens,fields),["="],[]),1); if ( attrib == "message" ) message = llList2String(llParseString2List(llList2String(tokens,fields),["="],[]),1); } if ( user != NULL_KEY && message != "" ) { llInstantMessage(user,message); } else { ERROR("Invalid INSTANTMESSAGE Command Received"); } return; } // STARTANIMATION|ANIMATION=uuid or name... if ( cmd == "startanimation" && fields == 2 ) { string animation = ""; while ( fields-- ) { string attrib = llToLower(llList2String(llParseString2List(llList2String(tokens,fields),["="],[]),0)); if ( attrib == "animation" ) animation = llList2String(llParseString2List(llList2String(tokens,fields),["="],[]),1); } if ( animation != "" ) { llStartAnimation(animation); // FIXME Permissions? Track list of running? } else { ERROR("Invalid STARTANIMATION Command Received"); } return; } // STOPANIMATION|ANIMATION=uuid or name in inventory or all if ( cmd == "stopanimation" && fields == 2 ) { string animation = ""; while ( fields-- ) { string attrib = llToLower(llList2String(llParseString2List(llList2String(tokens,fields),["="],[]),0)); if ( attrib == "animation" ) animation = llList2String(llParseString2List(llList2String(tokens,fields),["="],[]),1); } if ( llToLower(animation) == "all" ) { list animsrunning = llGetAnimationList(llGetOwner()); integer count = llGetListLength(animsrunning); while ( count--) { llStopAnimation(llList2String(animsrunning,count)); } return; } else if ( animation != "" ) { llStopAnimation(animation); // FIXME Permissions? Track list of running? } else { ERROR("Invalid STOPANIMATION Command Received"); } return; } // PLAYSOUND|SOUND=...|VOLUME=#.# - attached - does not play inworld from HUD if ( cmd == "playsound" && fields == 3 ) { string sound = ""; float volume = 0.0; while ( fields-- ) { string attrib = llToLower(llList2String(llParseString2List(llList2String(tokens,fields),["="],[]),0)); if ( attrib == "sound" ) sound = llList2String(llParseString2List(llList2String(tokens,fields),["="],[]),1); if ( attrib == "volume" ) volume = llList2Float(llParseString2List(llList2String(tokens,fields),["="],[]),1); } if ( sound != "" && volume != 0.0 ) { llPlaySound(sound,volume); } else { ERROR("Invalid PLAYSOUND Command Received"); } return; } // TRIGGERSOUND|SOUND=...|VOLUME=#.# - unattached, can play inworld from HUD if ( cmd == "triggersound" && fields == 3 ) { string sound = ""; float volume = 0.0; while ( fields-- ) { string attrib = llToLower(llList2String(llParseString2List(llList2String(tokens,fields),["="],[]),0)); if ( attrib == "sound" ) sound = llList2String(llParseString2List(llList2String(tokens,fields),["="],[]),1); if ( attrib == "volume" ) volume = llList2Float(llParseString2List(llList2String(tokens,fields),["="],[]),1); } if ( sound != "" && volume != 0.0 ) { llTriggerSound(sound,volume); } else { ERROR("Invalid TRIGGERSOUND Command Received"); } return; } // LOOPSOUND|SOUND=...|VOLUME=#.# - does not play inworld from HUD if ( cmd == "loopsound" && fields == 3 ) { string sound = ""; float volume = 0.0; while ( fields-- ) { string attrib = llToLower(llList2String(llParseString2List(llList2String(tokens,fields),["="],[]),0)); if ( attrib == "sound" ) sound = llList2String(llParseString2List(llList2String(tokens,fields),["="],[]),1); if ( attrib == "volume" ) volume = llList2Float(llParseString2List(llList2String(tokens,fields),["="],[]),1); } if ( sound != "" && volume != 0.0 ) { llLoopSound(sound,volume); } else { ERROR("Invalid LOOPSOUND Command Received"); } return; } // STOPSOUND if ( cmd == "stopsound" ) { llStopSound(); return; } // PARTICLEPRESET|NAME=presetname... if ( cmd == "particlepreset" && fields == 2 ) { string name = ""; while (fields--) { string attrib = llToLower(llList2String(llParseString2List(llList2String(tokens,fields),["="],[]),0)); if ( attrib == "name" ) name = llList2String(llParseString2List(llList2String(tokens,fields),["="],[]),1); } if ( name != "" ) { // found preset integer start = llListFindList(PRESETS,[name]) + 2; integer end = start + llList2Integer(PRESETS,start - 1); llParticleSystem(llList2List(PRESETS,start,end)); } else { ERROR("Invalid PARTICLEPRESET Command Received."); } return; } // PARTICLES|whoanelly // PARTICLESOFF if ( cmd == "particlesoff" ) { llParticleSystem([]); return; } } //------------------------------------------------------------------------ //------------------------------------------------------------------------ on_rez(integer start_param) { DEBUG("Rezzed with start_param "+(string)start_param+". Resetting."); RESET(); } //------------------------------------------------------------------------ //------------------------------------------------------------------------ run_time_permissions(integer perm) { if ( perm & PERMISSION_TRIGGER_ANIMATION) { DEBUG("PERMISSION_TRIGGER_ANIMATION granted."); } } //------------------------------------------------------------------------ //------------------------------------------------------------------------ state_entry() { SETUP(); } }