<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<muclient>

<plugin
 name="Elixsum"
 author="Trevize"
 id="f9a86b675c4c314dab7a7f03"
 language="Lua"
 purpose="Elixir Summary"
 requires="4.40"
 version="1.24">

<description trim="y">
<![CDATA[

Elixir Summary 1.2.4

ELIXSUM shows a summary of your vials and their contents.

-Trevize

]]>
</description>

</plugin>


<triggers>
  <trigger
   group="elixsum"
   keep_evaluating="y"
   match="^\d+h(, \d+m)?(, \d+e)?(, \d+w)? [@cexkdb]*(?: Vote)?-"
   omit_from_output="y"
   regexp="y"
   send_to="14"
   sequence="2">
    <send>
      prompt.data = TriggerStyleRuns
      elixsum.finish ()
    </send>
  </trigger>

  <trigger
   group="elixsum"
   match="^$"
   omit_from_output="y"
   regexp="y"
   sequence="50">
  </trigger>

  <trigger
   group="elixsum"
   match="^-{76}$"
   omit_from_output="y"
   regexp="y"
   sequence="50">
  </trigger>

  <trigger
   group="elixsum"
   match="^Vial\d+\s+a salve of ([a-z]+)\s+(\d+)\s+(?:\d+|---)$"
   omit_from_output="y"
   regexp="y"
   send_to="12"
   sequence="50">
    <send>
      elixsum.current.%1vials = elixsum.current.%1vials + 1
      elixsum.current.%1sips = elixsum.current.%1sips + %2
    </send>
  </trigger>

  <trigger
   group="elixsum"
   match="^Vial\d+\s+an elixir of ([a-z]+)\s+(\d+)\s+(?:\d+|---)$"
   omit_from_output="y"
   regexp="y"
   send_to="12"
   sequence="50">
    <send>
      elixsum.current.%1vials = elixsum.current.%1vials + 1
      elixsum.current.%1sips = elixsum.current.%1sips + %2
    </send>
  </trigger>

  <trigger
   group="elixsum"
   match="^Vial\d+\s+an? ([a-z]+) salve\s+(\d+)\s+(?:\d+|---)$"
   omit_from_output="y"
   regexp="y"
   send_to="12"
   sequence="50">
    <send>
      elixsum.current.%1vials = elixsum.current.%1vials + 1
      elixsum.current.%1sips = elixsum.current.%1sips + %2
    </send>
  </trigger>

  <trigger
   group="elixsum"
   match="^Vial\d+\s+empty\s+0\s+(?:\d+|---)$"
   omit_from_output="y"
   regexp="y"
   send_to="12"
   sequence="50">
    <send>elixsum.current.emptyvials = elixsum.current.emptyvials + 1</send>
  </trigger>

  <trigger
   group="elixsum"
   match="^Vial\d+\s+the venom [a-z]+\s+\d+\s+(?:\d+|---)$"
   omit_from_output="y"
   regexp="y"
   sequence="50">
  </trigger>

  <trigger
   group="elixsum"
   match="^Vial\s{26}Elixir\s{19}Sips\s{6}Months Left$"
   name="elixsumstart"
   omit_from_output="y"
   regexp="y"
   send_to="12"
   sequence="50">
    <send>
      EnableTriggerGroup ("elixsum", true)
      EnableTrigger ("elixsumstart", false)
    </send>
  </trigger>
</triggers>


<aliases>
  <alias match="^\s*elixsum\s*$"
   enabled="y"
   echo_alias="y"
   group="elixsum"
   regexp="y"
   send_to="12"
   keep_evaluating="y"
   sequence="100">
    <send>
      elixsum.reset ()
      EnableTrigger ("elixsumstart", true)
      SendNoEcho ("elixlist2")
    </send>
  </alias>
</aliases>


<script>
<![CDATA[

-- ============
--  foundation
-- ============

ansicolor = function (fore, back)
  local bold = false
  local fore = tonumber (fore) or 7
  if fore >= 0 and fore <= 7 then
    fore = fore + 30
  elseif fore >= 8 and fore <= 15 then
    fore = fore + 22
    bold = true
  else
    fore = 37
  end -- if
  local back = tonumber (back) or 0
  if back > 0 and back <= 7 then
    back = back + 40
  else
    back = 40
  end -- if
  if not bold then
    return ANSI (0, fore, back)
  else
    return ANSI (0, fore, 1, back)
  end -- if
end -- func

tpairs = function (tbl)
  local i = 0
  return function ()
    i = i + 1
    if tbl[i] ~= nil then return tbl[i] end
  end -- func
end -- func

prompt = {}
prompt.data = false
prompt.draw = function ()
  if prompt.data then
    for k,v in ipairs (prompt.data) do
      ColourTell (RGBColourToName (v.textcolour),
                  RGBColourToName (v.backcolour),
                  v.text)
    end -- for
  end -- if
  Note ("")
end -- func



-- =========
--  Elixsum
-- =========

elixsum = {
  ref = {"Health", "Mana",    "Frost",     "Immunity", "Levitation", "Speed",
         "Venom",  "Caloric", "Epidermal", "Mass",     "Mending",    "Restoration"},

  current = {
    healthvials      = 0, healthsips      = 0,
    manavials        = 0, manasips        = 0,
    frostvials       = 0, frostsips       = 0,
    immunityvials    = 0, immunitysips    = 0,
    levitationvials  = 0, levitationsips  = 0,
    speedvials       = 0, speedsips       = 0,
    venomvials       = 0, venomsips       = 0,
    caloricvials     = 0, caloricsips     = 0,
    epidermalvials   = 0, epidermalsips   = 0,
    massvials        = 0, masssips        = 0,
    mendingvials     = 0, mendingsips     = 0,
    restorationvials = 0, restorationsips = 0,
    emptyvials       = 0},

  finish = function ()
    AnsiNote (ansicolor (7), "Elixir         Sips  Vials")
    AnsiNote (ansicolor (7), "--------------------------")
    for v in tpairs (elixsum.ref) do elixsum.display (v) end
    AnsiNote (ansicolor (), string.format ("%s %20s", "Empty", elixsum.current["emptyvials"]))
    EnableTriggerGroup ("elixsum", false)
    prompt.draw ()
  end, -- func

  display = function (vial)
    AnsiNote (ansicolor (), string.format ("%-11s %7s %6s", vial,
              elixsum.current[string.lower (vial) .. "sips"], 
              elixsum.current[string.lower (vial) .. "vials"]))
  end, -- func

  reset = function ()
    for k in pairs (elixsum.current) do elixsum.current[k] = 0 end
  end, -- func
  }

]]>
</script>

</muclient>