<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<muclient>

<plugin
   name="Shards"
   author="Trevize"
   id="f9a86b675c4c314dab7a7f05"
   language="Lua"
   purpose="Shard Counter"
   requires="4.14"
   version="1.2"
   >

<description trim="y">
<![CDATA[

Shard Counter 1.2

SHARDS checks the weight of your shards and displays the results
STI begins strengthening and continues as long as you have shards

Enjoy!

-Trevize

]]>
</description>

</plugin>


<triggers>

  <trigger group="shardpreinv" keep_evaluating="y" match="^You are wielding\:$" omit_from_output="y" regexp="y" send_to="12" sequence="100">
    <send>
      EnableTriggerGroup("shardinv", true)
      EnableTriggerGroup("shardpreinv", false)
    </send>
  </trigger>

  <trigger group="shardpreinv" keep_evaluating="y" match="^You aren't wielding anything in either hand\.$" omit_from_output="y" regexp="y" send_to="12" sequence="100">
    <send>
      EnableTriggerGroup("shardinv", true)
      EnableTriggerGroup("shardpreinv", false)
    </send>
  </trigger>

  <trigger group="shardinv" keep_evaluating="y" match="\s+shard+(\d+)\s+a (?:smooth|jagged|chipped) iconic shard$" omit_from_output="y" regexp="y" send_to="12" sequence="100">
    <send>
      shardcount = shardcount + 1
      shardnum = shardnum + 1
      shards[shardnum] = "%1"
    </send>
  </trigger>

  <trigger group="shardinv" keep_evaluating="y" match="^\s+[a-z]+\d+\s?: .*? in your (?:left hand|right hand|hands)\.$" omit_from_output="y" regexp="y" sequence="100">
  </trigger>

  <trigger group="shardinv" keep_evaluating="y" match="^You are holding\:$" omit_from_output="y" regexp="y" sequence="100">
  </trigger>

  <trigger group="shardinv" keep_evaluating="y" match="^\s*$" omit_from_output="y" regexp="y" sequence="100">
  </trigger>

  <trigger group="shardinv" match="^\[Type MORE if you wish to continue reading\. \(\d+\% shown\)\]$" omit_from_output="y" regexp="y" send_to="12" sequence="100">
    <send>
      domore = true
    </send>
  </trigger>

  <trigger group="shardinv" match="^\d+h, \d+(?:m|e).*" omit_from_output="y" regexp="y" send_to="14" sequence="100">
    <send>
      if domore then
        domore = false
        SendNoEcho ("more")
      else
        shardcheck ()
      end -- if
    </send>
  </trigger>

  <trigger group="shardprobe" match="^This strange\-looking shard is made of a stone\-like material and" omit_from_output="y" regexp="y" sequence="100">
  </trigger>

  <trigger group="shardprobe" match="^perfectly smooth, emulating on a small scale" omit_from_output="y" regexp="y" sequence="100">
  </trigger>

  <trigger group="shardprobe" match="^empowers. A purple phosphorescent miasma swathes" omit_from_output="y" regexp="y" sequence="100">
  </trigger>

  <trigger group="shardprobe" match="^(?:sparks )?of energy zing through the" omit_from_output="y" regexp="y" sequence="100">
  </trigger>

  <trigger group="shardprobe" match="^(?:Almost )?hidden by the intense glow" omit_from_output="y" regexp="y" sequence="100">
  </trigger>

  <trigger group="shardprobe" match="^(?:glitter )?bizarrely with their own" omit_from_output="y" regexp="y" sequence="100">
  </trigger>

  <trigger group="shardprobe" match="^(?:chipped|jagged) edges as if it had been cloven" omit_from_output="y" regexp="y" sequence="100">
  </trigger>

  <trigger group="shardprobe" match="^(?:thick cloud around|from) it, giving off a soft" omit_from_output="y" regexp="y" sequence="100">
  </trigger>

  <trigger group="shardprobe" match="^(?:faintly. Inscribed )?upon the shard's smooth" omit_from_output="y" regexp="y" sequence="100">
  </trigger>

  <trigger group="shardprobe" match="^(?:alloy-filled )?(?:glyphs that )?glitter strangely with a light" omit_from_output="y" regexp="y" sequence="100">
  </trigger>

  <trigger group="shardprobe" match="^It has about a month of usefulness left\.$" omit_from_output="y" regexp="y" sequence="100">
  </trigger>

  <trigger group="shardprobe" match="^It weighs (\d+) ounce\(s\)\.$" omit_from_output="y" regexp="y" send_to="12" sequence="100">
    <send>
      shardcount = shardcount - 1
      totalounces = totalounces + %1
      limitounces()
    </send>
  </trigger>

  <trigger group="shardprobe" match="^It weighs about (\d+) pounds? and (\d+) ounce\(s\)\.$" omit_from_output="y" regexp="y" send_to="12" sequence="100">
    <send>
      shardcount = shardcount - 1
      totalpounds = totalpounds + %1
      totalounces = totalounces + %2
      limitounces()
    </send>
  </trigger>

  <trigger group="shardprobe" match="^It weighs about (\d+) pounds?\.$" omit_from_output="y" regexp="y" send_to="12" sequence="100">
    <send>
      shardcount = shardcount - 1
      totalpounds = totalpounds + %1
    </send>
  </trigger>

  <trigger group="shardprobe" match="^\d+h, \d+(?:m|e).*" omit_from_output="y" regexp="y" send_to="14" sequence="100">
    <send>
      if shardcount == 0 then
        shardfinish ()
      end -- if
    </send>
  </trigger>

  <trigger enabled="y" match="^You feel a momentary burst of energy as the iconic shard in your hand is finally absorbed\, increasing the power of the House Icon\.$" regexp="y" send_to="12" sequence="100">
    <send>
      SendNoEcho ("strengthen icon")
    </send>
  </trigger>

  <trigger enabled="y" match="^You may not strengthen an Icon without an iconic shard in your possession\.$" omit_from_output="y" regexp="y" send_to="14" sequence="100">
    <send>
      ColourNote ("silver", "black", "All shards used.")
    </send>
  </trigger>

  <trigger enabled="y" match="^I see no icon here\.$" omit_from_output="y" regexp="y" send_to="14" sequence="100">
    <send>
      ColourNote ("silver", "black", "No icon present.")
    </send>
  </trigger>

</triggers>

<aliases>

  <alias match="^shards$" enabled="y" regexp="y" send_to="12" ignore_case="y" sequence="100">
    <send>
      EnableTriggerGroup("shardpreinv", true)
      domore = false
      shardblank ()
      SendNoEcho ("info hold shard")
      ColourNote ("silver", "black", "Calculating shard weight.")
    </send>
  </alias>

  <alias match="^sti$" enabled="y" regexp="y" send_to="12" ignore_case="y" sequence="100">
    <send>
      SendNoEcho ("strengthen icon")
    </send>
  </alias>

</aliases>

<script>
<![CDATA[

function shardblank ()
  shardnum = 0
  shardcount = 0
  totalounces = 0
  totalpounds = 0
  shards = {}
end -- func

function limitounces ()
  if totalounces > 15 then
    totalounces = totalounces - 16
    totalpounds = totalpounds + 1
  end -- if
end -- func

function shardcheck ()
  if shardnum == 0 then
    ColourNote ("silver", "black", "You have no shards.")
    SendNoEcho ("")
  else
    EnableTriggerGroup ("shardprobe", true)
    for i=1, shardnum do
      SendNoEcho ("probe " .. shards[i])
    end -- for
  end -- if
  EnableTriggerGroup ("shardinv", false)
end -- func

function shardfinish ()
  ColourTell ("silver", "black", "You have ")
  ColourTell ("silver", "black", shardnum)
  if shardnum == 1 then
    ColourTell ("silver", "black", " shard, weighing ")
  else
    ColourTell ("silver", "black", " shards, weighing a total of ")
  end -- if
  ColourTell ("silver", "black", totalpounds)
  if totalpounds == 1 then
    ColourTell ("silver", "black", " pound and ")
  else
    ColourTell ("silver", "black", " pounds and ")
  end -- if
    ColourTell ("silver", "black", totalounces)
  if totalounces == 1 then
    ColourNote ("silver", "black", " ounce.")
  else
    ColourNote ("silver", "black", " ounces.")
  end -- if
  SendNoEcho ("")
  EnableTriggerGroup ("shardprobe", false)
  shardblank ()
end -- func

]]>
</script>

</muclient>

