<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<muclient>

<plugin
 name="Tattoos"
 author="Trevize"
 id="f9a86b675c4c314dab7a7f02"
 language="Lua"
 purpose="Tattoo Display"
 requires="4.40"
 version="1.32">

<description trim="y">
<![CDATA[

Tattoo Display 1.3.2

TATTOOS shows the tattoos on yourself or another person in a much easier to read format.

Enjoy!

-Trevize

]]>
</description>

</plugin>


<triggers>
  <trigger
   keep_evaluating="y"
   match="^\d+h(, \d+m)?(, \d+e)?(, \d+w)? [@cexkdb]*(?: Vote)?-"
   name="prompt"
   omit_from_output="y"
   regexp="y"
   send_to="14"
   sequence="2">
    <send>
      prompt.data = TriggerStyleRuns
      tattoos.finish ()
    </send>
  </trigger>

  <trigger
   group="tattoogag"
   match="^-+$"
   omit_from_output="y"
   regexp="y"
   send_to="14"
   sequence="100">
    <send>EnableTriggerGroup ("tattoogag", false)</send>
  </trigger>

  <trigger
   group="tattoogag"
   match="^Body Part  Tattoo\s{27}Charges(?:  Active)?$"
   omit_from_output="y"
   regexp="y"
   sequence="100">
  </trigger>

  <trigger
   enabled="y"
   group="tattoos"
   match="^Looking over \w+, you see the following tattoos\:$"
   regexp="y"
   send_to="14"
   sequence="100">
    <send>
      tattoos.blank ()
      EnableTriggerGroup ("tattoogag", true)
      EnableTrigger ("tattoo", true)
      EnableTrigger ("prompt", true)
    </send>
  </trigger>

  <trigger
   enabled="y"
   group="tattoos"
   match="^Looking over yourself, you see the following tattoos\:$"
   omit_from_output="y"
   regexp="y"
   send_to="14"
   sequence="50">
    <send>
      tattoos.blank ()
      EnableTriggerGroup ("tattoogag", true)
      EnableTrigger ("tattoo", true)
      EnableTrigger ("prompt", true)
    </send>
  </trigger>

  <trigger
   group="tattoos"
   match="^(.+?)\s{2,}a (.+?) tattoo\s+(?:(\d+)|n\/a)(?:\s+[YN!])?$"
   name="tattoo"
   omit_from_output="y"
   regexp="y"
   send_to="14"
   sequence="100">
    <send>
      local bodypart = string.lower ("%1")
      if not tattoos.current[bodypart] then
        tattoos.current[bodypart] = "%2"
        if "%3" ~= "" then tattoos.current[bodypart.." uses"] = "%3" end
      else
        tattoos.current[bodypart.." ss"] = "%2"
        if "%3" ~= "" then tattoos.current[bodypart.." ss uses"] = "%3" end
      end -- if
    </send>
  </trigger>
</triggers>


<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



-- =========
--  tattoos
-- =========

tattoos = {
  current = {
    ["head"]         = false, ["head uses"]         = false,
    ["torso"]        = false, ["torso uses"]        = false,
    ["left arm"]     = false, ["left arm uses"]     = false,
    ["right arm"]    = false, ["right arm uses"]    = false,
    ["left leg"]     = false, ["left leg uses"]     = false,
    ["right leg"]    = false, ["right leg uses"]    = false,
    ["head ss"]      = false, ["head ss uses"]      = false,
    ["torso ss"]     = false, ["torso ss uses"]     = false,
    ["left arm ss"]  = false, ["left arm ss uses"]  = false,
    ["right arm ss"] = false, ["right arm ss uses"] = false,
    ["left leg ss"]  = false, ["left leg ss uses"]  = false,
    ["right leg ss"] = false, ["right leg ss uses"] = false,
    },

  blank = function ()
    for k in pairs (tattoos.current) do tattoos.current[k] = false end
  end, -- func

  finish = function ()
    EnableTrigger ("tattoo", false)
    EnableTrigger ("prompt", false)
    tattoos.prompt = false
    AnsiNote (ansicolor (), "Bodypart   Tattoos")
    AnsiNote (ansicolor (), "--------   -------")
    tattoos.display ("Head")
    tattoos.display ("Torso")
    tattoos.display ("Left Arm")
    tattoos.display ("Right Arm")
    tattoos.display ("Left Leg")
    tattoos.display ("Right Leg")
    prompt.draw ()
  end, -- func

  display = function (bodypart)
    local x = bodypart
    if tattoos.current[string.lower (bodypart)] then
      x = string.format ("%-11s%s", x, tattoos.current[string.lower (bodypart)])
      if tattoos.current[string.lower (bodypart) .. " uses"] then
        x = x .. " (" .. tattoos.current[string.lower (bodypart) .. " uses"] .. ")"
      end -- if
      if tattoos.current[string.lower (bodypart) .. " ss"] then
        x = string.format ("%-26s%s", x, tattoos.current[string.lower (bodypart) .. " ss"])
        if tattoos.current[string.lower (bodypart) .. " ss uses"] then
          x = x .. " (" .. tattoos.current[string.lower (bodypart) .. " ss uses"] .. ")"
        end -- if
      end -- if
    end -- if
    AnsiNote (ansicolor (), x)
  end, -- func
  }

]]>
</script>

</muclient>