<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://opensimulator.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://opensimulator.org/index.php?action=history&amp;feed=atom&amp;title=User%3AAllen_Kerensky%2FMyriad_Lite%2FMyriad_Lite_Meter-v0.0.7-20120827.lsl</id>
		<title>User:Allen Kerensky/Myriad Lite/Myriad Lite Meter-v0.0.7-20120827.lsl - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://opensimulator.org/index.php?action=history&amp;feed=atom&amp;title=User%3AAllen_Kerensky%2FMyriad_Lite%2FMyriad_Lite_Meter-v0.0.7-20120827.lsl"/>
		<link rel="alternate" type="text/html" href="http://opensimulator.org/index.php?title=User:Allen_Kerensky/Myriad_Lite/Myriad_Lite_Meter-v0.0.7-20120827.lsl&amp;action=history"/>
		<updated>2026-06-13T18:14:41Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.19.9</generator>

	<entry>
		<id>http://opensimulator.org/index.php?title=User:Allen_Kerensky/Myriad_Lite/Myriad_Lite_Meter-v0.0.7-20120827.lsl&amp;diff=30559&amp;oldid=prev</id>
		<title>Allen Kerensky: Myriad_Lite_Meter-v0.0.7-20120827.lsl</title>
		<link rel="alternate" type="text/html" href="http://opensimulator.org/index.php?title=User:Allen_Kerensky/Myriad_Lite/Myriad_Lite_Meter-v0.0.7-20120827.lsl&amp;diff=30559&amp;oldid=prev"/>
				<updated>2012-08-28T01:40:24Z</updated>
		
		<summary type="html">&lt;p&gt;Myriad_Lite_Meter-v0.0.7-20120827.lsl&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Myriad_Lite_Meter-v0.0.7-20120827.lsl =&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;lsl&amp;quot;&amp;gt;&lt;br /&gt;
// Myriad_Lite_Meter-v0.0.7-20120827.lsl&lt;br /&gt;
// Copyright (c) 2012 by Allen Kerensky (OSG/SL) All Rights Reserved.&lt;br /&gt;
// This work is dual-licensed under&lt;br /&gt;
// Creative Commons Attribution (CC BY) 3.0 Unported&lt;br /&gt;
// http://creativecommons.org/licenses/by/3.0/&lt;br /&gt;
// - or -&lt;br /&gt;
// Modified BSD License (3-clause)&lt;br /&gt;
// Redistribution and use in source and binary forms, with or without&lt;br /&gt;
// modification, are permitted provided that the following conditions are met:&lt;br /&gt;
// * Redistributions of source code must retain the above copyright notice, &lt;br /&gt;
//   this list of conditions and the following disclaimer.&lt;br /&gt;
// * Redistributions in binary form must reproduce the above copyright notice,&lt;br /&gt;
//   this list of conditions and the following disclaimer in the documentation&lt;br /&gt;
//   and/or other materials provided with the distribution.&lt;br /&gt;
// * Neither the name of Myriad Lite nor the names of its contributors may be&lt;br /&gt;
//   used to endorse or promote products derived from this software without&lt;br /&gt;
//   specific prior written permission.&lt;br /&gt;
//&lt;br /&gt;
// THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR&lt;br /&gt;
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES&lt;br /&gt;
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN&lt;br /&gt;
// NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,&lt;br /&gt;
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT&lt;br /&gt;
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,&lt;br /&gt;
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY&lt;br /&gt;
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT&lt;br /&gt;
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF&lt;br /&gt;
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
//&lt;br /&gt;
// The Myriad RPG System was designed, written, and illustrated by Ashok Desai&lt;br /&gt;
// Myriad RPG System licensed under:&lt;br /&gt;
// Creative Commons Attribution (CC BY) 2.0 UK: England and Wales&lt;br /&gt;
// http://creativecommons.org/licenses/by/2.0/uk/&lt;br /&gt;
&lt;br /&gt;
//============================================================================&lt;br /&gt;
// MESSAGE FORMAT REFERENCE&lt;br /&gt;
//============================================================================&lt;br /&gt;
// CHANPLAYER IN - METER|str PLAYER NAME|str GAMENAME|int CURWOUNDS|int MAXWOUNDS|int CURCRITICAL|int MAXCRITICAL|int ISDEAD|int ISINCAPACITATED&lt;br /&gt;
     &lt;br /&gt;
//============================================================================&lt;br /&gt;
// GLOBAL VARIABLES&lt;br /&gt;
//============================================================================&lt;br /&gt;
string  VERSION = &amp;quot;0.0.7&amp;quot;; // version number&lt;br /&gt;
string  VERDATE = &amp;quot;20120827&amp;quot;; // version date&lt;br /&gt;
integer FLAG_DEBUG; // show debugging messages?&lt;br /&gt;
integer CHANATTACH; // dynamic channel for player attachments &lt;br /&gt;
integer HANDATTACH; // attach channel handle for llRemove&lt;br /&gt;
string CHAN_PREFIX = &amp;quot;0x&amp;quot;; // prefix to convert to hexadecimal&lt;br /&gt;
string DIV = &amp;quot;|&amp;quot;; // Myriad message field divider&lt;br /&gt;
string FORMATSTRING = &amp;quot; @GN \n @HP \n @ST &amp;quot;; // GN = GameName, HP = HealthPercent, ST = Status (incap, dead, etc)&lt;br /&gt;
string  STATUS; // settext message&lt;br /&gt;
vector  COLOR = &amp;lt;0,1,0&amp;gt;; // set text color&lt;br /&gt;
float   ALPHA = 1.0; // set text alpha 0.0 = clear, 1.0 = solid&lt;br /&gt;
vector GREEN = &amp;lt;0,1,0&amp;gt;; // color constant for convenience&lt;br /&gt;
vector YELLOW = &amp;lt;1,1,0&amp;gt;; // color constant for convenience&lt;br /&gt;
vector RED = &amp;lt;1,0,0&amp;gt;; // color constant for convencience&lt;br /&gt;
vector BLACK = &amp;lt;0,0,0&amp;gt;; // color constant for convenience&lt;br /&gt;
&lt;br /&gt;
//============================================================================&lt;br /&gt;
// DEBUG&lt;br /&gt;
//============================================================================&lt;br /&gt;
DEBUG(string debugmsg) {&lt;br /&gt;
    if ( FLAG_DEBUG == TRUE ) llSay(DEBUG_CHANNEL,&amp;quot;(&amp;quot;+llKey2Name(llGetOwner())+&amp;quot;) METER DEBUG: &amp;quot;+debugmsg);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//============================================================================&lt;br /&gt;
// HEALTHPERCENT - generate a percentage health status&lt;br /&gt;
//============================================================================&lt;br /&gt;
string HEALTHPERCENT(integer curwounds,integer maxwounds,integer curcritical,integer maxcritical) {&lt;br /&gt;
    string out;&lt;br /&gt;
    float currentpoints = (float)curwounds + (float)curcritical; // add up noncritical and critical wounds boxes remaining&lt;br /&gt;
    float maxpoints = (float)maxwounds + (float)maxcritical; // add up total wounds boxes player should have&lt;br /&gt;
    if ( currentpoints &amp;gt; 0.0 ) { // if player has some wounds left&lt;br /&gt;
        float health = ( ( currentpoints / maxpoints ) * 100.0 ); // get a percentage&lt;br /&gt;
        out = &amp;quot;Health: &amp;quot;+(string)llRound(health)+&amp;quot;%&amp;quot;; // add the percentage health to the status&lt;br /&gt;
    } else { // oops all resilience gone&lt;br /&gt;
        out = &amp;quot;Health: 0%&amp;quot;; // so add a zero% to status&lt;br /&gt;
    }&lt;br /&gt;
    return out;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//============================================================================&lt;br /&gt;
// SEARCHANDREPLACE - search and replace tokens&lt;br /&gt;
//============================================================================&lt;br /&gt;
string SEARCHANDREPLACE(string input, string old, string new)  {&lt;br /&gt;
   return llDumpList2String(llParseString2List(input, [old], []), new);&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
//============================================================================&lt;br /&gt;
// SETUP()&lt;br /&gt;
//============================================================================&lt;br /&gt;
SETUP() {&lt;br /&gt;
    FLAG_DEBUG = FALSE;&lt;br /&gt;
    llSetText(&amp;quot;--- Waiting for Myriad Update ---&amp;quot;,&amp;lt;1,0,0&amp;gt;,1); // set a default banner to show we haven't been updated yet&lt;br /&gt;
    CHANATTACH = (integer)(CHAN_PREFIX+llGetSubString((string)llGetOwner(),1,7)); // calculate wearer's dynamic attachment channel&lt;br /&gt;
    if ( HANDATTACH != 0 ) llListenRemove(HANDATTACH); // remove previously open channel&lt;br /&gt;
    HANDATTACH = llListen(CHANATTACH,&amp;quot;&amp;quot;,NULL_KEY,&amp;quot;&amp;quot;); // start a listener on the dynamic channel&lt;br /&gt;
    llWhisper(CHANATTACH,&amp;quot;ATTACHMETER&amp;quot;); // tell HUD we're attached&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//============================================================================&lt;br /&gt;
// DEFAULT STATE&lt;br /&gt;
//============================================================================&lt;br /&gt;
default {&lt;br /&gt;
&lt;br /&gt;
    //------------------------------------------------------------------------&lt;br /&gt;
    // ATTACH EVENT&lt;br /&gt;
    //------------------------------------------------------------------------    &lt;br /&gt;
    attach(key id) { // &lt;br /&gt;
        if ( id != NULL_KEY ) {&lt;br /&gt;
            SETUP(); // wearing, let's setup&lt;br /&gt;
            return;&lt;br /&gt;
        }        &lt;br /&gt;
        if ( id == NULL_KEY ) { // detach, drop, derezzed to inventory - NOT ON LOGOUT&lt;br /&gt;
            if ( HANDATTACH != 0 ) llListenRemove(HANDATTACH);&lt;br /&gt;
            llWhisper(CHANATTACH,&amp;quot;DETACHMETER&amp;quot;);&lt;br /&gt;
            return;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    //------------------------------------------------------------------------&lt;br /&gt;
    // CHANGED EVENT&lt;br /&gt;
    //------------------------------------------------------------------------    &lt;br /&gt;
    changed(integer changes) {&lt;br /&gt;
        if ( changes &amp;amp; CHANGED_OWNER ) { // if owner has changed, we need to recalculate the dynamic channel&lt;br /&gt;
            SETUP(); // setup the hovertext meter&lt;br /&gt;
            return;&lt;br /&gt;
        }&lt;br /&gt;
        if ( changes &amp;amp; CHANGED_REGION || changes &amp;amp; CHANGED_TELEPORT ) { // owner jumped to new location? restart&lt;br /&gt;
            SETUP(); // setup hovertext and channel&lt;br /&gt;
            return;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //------------------------------------------------------------------------&lt;br /&gt;
    // LISTEN EVENT&lt;br /&gt;
    //------------------------------------------------------------------------    &lt;br /&gt;
    listen(integer channel,string name,key id,string message) {&lt;br /&gt;
        DEBUG(&amp;quot;listen(&amp;quot;+(string)channel+&amp;quot;,&amp;quot;+name+&amp;quot;,&amp;quot;+(string)id+&amp;quot;,&amp;quot;+message+&amp;quot;)&amp;quot;);&lt;br /&gt;
        if ( channel == CHANATTACH ) { // did this message come in on attachment channel?&lt;br /&gt;
            list fields = llParseString2List(message,[DIV],[]); // break message down into list separated by |&lt;br /&gt;
            string command = llList2String(fields,0); // read first item in list to get the Myriad command&lt;br /&gt;
            if ( command == &amp;quot;METER&amp;quot;) { // if this is the METER command, let's update the meter status&lt;br /&gt;
                string playername   = llList2String(fields,1); // get the full player name from the list of METER values&lt;br /&gt;
                list   name2        = llParseString2List(playername,[&amp;quot; &amp;quot;],[]); // separate first and last name by space&lt;br /&gt;
                string firstname    = llList2String(name2,0); // get the firstname from the name2&lt;br /&gt;
                string lastname     = llList2String(name2,1); // get the lastname, if any, from the name2&lt;br /&gt;
                string gamename     = llList2String(fields,2); // get player's alias/game name (originally set in their character sheet)&lt;br /&gt;
                integer curwounds   = llList2Integer(fields,3); // what is player's current wound value?&lt;br /&gt;
                integer maxwounds   = llList2Integer(fields,4); // what is player's maximum healed wounds allowed by level/stats?&lt;br /&gt;
                integer curcritical = llList2Integer(fields,5); // what is player's current critical wounds value?&lt;br /&gt;
                integer maxcritical = llList2Integer(fields,6); // what is player's maximum healed critical wounds value?&lt;br /&gt;
                integer isdead      = llList2Integer(fields,7); // is player dead?&lt;br /&gt;
                integer isincap     = llList2Integer(fields,8); // is player incapacitated?&lt;br /&gt;
                string  species     = llList2String(fields,9); // player species&lt;br /&gt;
                string  background  = llList2String(fields,10); // player background&lt;br /&gt;
                string  career      = llList2String(fields,11); // player career&lt;br /&gt;
                &lt;br /&gt;
                // okay, we've broken down status, lets create a banner from that using colors&lt;br /&gt;
                STATUS = FORMATSTRING; // start with a default FORMATSTRING&lt;br /&gt;
                STATUS = SEARCHANDREPLACE(STATUS,&amp;quot;@PN&amp;quot;,playername); // @PN = Player Name&lt;br /&gt;
                STATUS = SEARCHANDREPLACE(STATUS,&amp;quot;@FN&amp;quot;,firstname); // @FN = First Name&lt;br /&gt;
                STATUS = SEARCHANDREPLACE(STATUS,&amp;quot;@LN&amp;quot;,lastname); // @PN = Last Name                &lt;br /&gt;
                STATUS = SEARCHANDREPLACE(STATUS,&amp;quot;@GN&amp;quot;,gamename); // @GN = Game Name&lt;br /&gt;
                STATUS = SEARCHANDREPLACE(STATUS,&amp;quot;@CW&amp;quot;,(string)curwounds); // @CW = Current Wounds&lt;br /&gt;
                STATUS = SEARCHANDREPLACE(STATUS,&amp;quot;@MW&amp;quot;,(string)maxwounds); // @MW = Max Wounds&lt;br /&gt;
                STATUS = SEARCHANDREPLACE(STATUS,&amp;quot;@CC&amp;quot;,(string)curcritical); // @CC = Current Critical                &lt;br /&gt;
                STATUS = SEARCHANDREPLACE(STATUS,&amp;quot;@MC&amp;quot;,(string)maxcritical); // @MC = Max Critical&lt;br /&gt;
                if ( isincap == 1 &amp;amp;&amp;amp; isdead == 0 ) {&lt;br /&gt;
                    STATUS = SEARCHANDREPLACE(STATUS,&amp;quot;@ST&amp;quot;,&amp;quot; ! INCAPACITATED ! &amp;quot;); // @ST = Status&lt;br /&gt;
                } else if ( isdead == 1 ) {&lt;br /&gt;
                    STATUS = SEARCHANDREPLACE(STATUS,&amp;quot;@ST&amp;quot;,&amp;quot; !!! DEAD !!! &amp;quot;); // @ST = Status&lt;br /&gt;
                } else {&lt;br /&gt;
                    STATUS = SEARCHANDREPLACE(STATUS,&amp;quot;@ST&amp;quot;,&amp;quot;&amp;quot;); // @ST = Status&lt;br /&gt;
                }&lt;br /&gt;
                STATUS = SEARCHANDREPLACE(STATUS,&amp;quot;@SP&amp;quot;,species); // @SP = Species&lt;br /&gt;
                STATUS = SEARCHANDREPLACE(STATUS,&amp;quot;@BG&amp;quot;,background); // @BG = Background Name&lt;br /&gt;
                STATUS = SEARCHANDREPLACE(STATUS,&amp;quot;@CA&amp;quot;,career); // @CA = Career&lt;br /&gt;
                string hp = HEALTHPERCENT(curwounds,maxwounds,curcritical,maxcritical);&lt;br /&gt;
                STATUS = SEARCHANDREPLACE(STATUS,&amp;quot;@HP&amp;quot;,hp); // @HP = Health Percent&lt;br /&gt;
                // PICK Color based on status&lt;br /&gt;
                COLOR = GREEN; // start with fully healthy color&lt;br /&gt;
                if ( curwounds == maxwounds &amp;amp;&amp;amp; curcritical == maxcritical ) { COLOR = GREEN; } // are all health boxes full?&lt;br /&gt;
                if ( curwounds &amp;lt; maxwounds &amp;amp;&amp;amp; curwounds &amp;gt;= 1 ) { COLOR = YELLOW; } // we've lost some wounds, but not incapacitated&lt;br /&gt;
                if ( curwounds &amp;lt; 1 ) { COLOR = RED; } // if we're out of non-critical wounds, we're bleeding out&lt;br /&gt;
                if ( isincap == 1 &amp;amp;&amp;amp; isdead == 0 ) { COLOR = RED;} // set color to warning that we're down but not dead yet&lt;br /&gt;
                if ( isdead == 1 ) { COLOR = BLACK; } // if we're dead&lt;br /&gt;
                llSetText(STATUS,COLOR,ALPHA); // show the new status text over the meter&lt;br /&gt;
                return; // we're done with this command, exit entire listen event&lt;br /&gt;
            } // end if command meter&lt;br /&gt;
            if ( command == &amp;quot;REGISTERATTACHMENTS&amp;quot; ) { // HUD asking for attachments attached?&lt;br /&gt;
                SETUP(); // just setup&lt;br /&gt;
                return;&lt;br /&gt;
            }&lt;br /&gt;
        } // end if chanattach&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //------------------------------------------------------------------------&lt;br /&gt;
    // ON_REZ EVENT&lt;br /&gt;
    //------------------------------------------------------------------------    &lt;br /&gt;
    on_rez(integer param) {&lt;br /&gt;
        param = 0; // LSLINT&lt;br /&gt;
        SETUP(); // setup the hovertext meter&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //------------------------------------------------------------------------&lt;br /&gt;
    // STATE_ENTRY EVENT&lt;br /&gt;
    //------------------------------------------------------------------------    &lt;br /&gt;
    state_entry() {&lt;br /&gt;
        SETUP(); // setup the hovertext meter&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
} // end default&lt;br /&gt;
//============================================================================&lt;br /&gt;
// END&lt;br /&gt;
//============================================================================&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Allen Kerensky</name></author>	</entry>

	</feed>