<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<muclient>

<plugin
 name="Pacts"
 author="Trevize"
 id="f9a86b675c4c314dab7a7f06"
 language="Lua"
 purpose="Pact Display"
 requires="4.40"
 version="1.32">

<description trim="y">
<![CDATA[

Pact Display 1.3.2

PACTS shows your pacts in a much easier to read format.

Enjoy!

-Trevize

]]>
</description>

</plugin>


<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   match="^You have formed a pact, (\d+) summons remaining, with (?:Jy\'Barrak )?(@!chaoslords).*$"
   omit_from_output="y"
   regexp="y"
   send_to="14"
   sequence="50">
    <send>
      if not pacts.active then
        pacts.reset ()
        pacts.active = true
      end -- if
      pacts.current["%2"] = %1
      EnableTriggerGroup ("pacts", true)
    </send>
  </trigger>

  <trigger
   group="pacts"
   keep_evaluating="y"
   match="^\d+h(, \d+m)?(, \d+e)?(, \d+w)? [@cexkdb]*(?: Vote)?-"
   omit_from_output="y"
   regexp="y"
   send_to="14"
   sequence="25">
    <send>
      prompt.data = TriggerStyleRuns
      pacts.finish ()
      pacts.active = false
      EnableTriggerGroup ("pacts", false)
    </send>
  </trigger>

  <trigger
   group="pacts"
   match="^(?:bloodleech pool|Glaaki|Hounds|Master|chaos gate|Chaos)$"
   omit_from_output="y"
   regexp="y"
   sequence="50">
  </trigger>
</triggers>


<variables>
  <variable name="chaoslords">Skyrax|Rixil|Eerion|Arctar|Scrag|Pyradius|Dameron|Palpatar|Nin'Kharsag|Istria|Marduk|Nemesis|Buul|Cadmus|Piridon|Danaeus|Xenophage|Lycantha|Hecate|Golgotha</variable>
</variables>


<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

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



-- =======
--  pacts
-- =======

pacts = {
  active = true,

  current = {
    ["Skyrax"] = 0,
    ["Rixil"] = 0,
    ["Eerion"] = 0,
    ["Arctar"] = 0,
    ["Scrag"] = 0,
    ["Pyradius"] = 0,
    ["Dameron"] = 0,
    ["Palpatar"] = 0,
    ["Nin'Kharsag"] = 0,
    ["Istria"] = 0,
    ["Marduk"] = 0,
    ["Nemesis"] = 0,
    ["Buul"] = 0,
    ["Cadmus"] = 0,
    ["Piridon"] = 0,
    ["Danaeus"] = 0,
    ["Xenophage"] = 0,
    ["Lycantha"] = 0,
    ["Hecate"] = 0,
    ["Golgotha"] = 0,
    },

  order = {
    "Skyrax", "Rixil", "Eerion", "Arctar", "Scrag",
    "Pyradius", "Dameron", "Palpatar", "Nin'Kharsag",
    "Istria", "Marduk", "Nemesis", "Buul", "Cadmus",
    "Piridon", "Danaeus", "Xenophage", "Lycantha",
    "Hecate", "Golgotha"
    },

  reset = function ()
    for k in pairs (pacts.current) do
      pacts.current[k] = 0
    end -- for
  end, -- func

  finish = function ()
    AnsiNote (ansicolor (), "Entity       Pacts")
    AnsiNote (ansicolor (), "------       -----")
    for k, v in ipairs (pacts.order) do pacts.display (v) end
    prompt.draw ()
  end, -- func

  display = function (entity)
    AnsiNote (ansicolor (), string.format ("%-11s %6s", entity, pacts.current[entity]))
  end, -- func
  }

]]>
</script>

</muclient>
