<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Monday, May 30, 2011, 10:24 PM -->
<!-- MuClient version 4.73 -->

<!-- Plugin "Rewear" generated by Plugin Wizard -->

<muclient>
<plugin
   name="ReWear"
   author="Kalvon"
   id="decd947e988688071c27f575"
   language="Lua"
   purpose="Re-orders your clothing"
   date_written="2011-05-30 22:22:14"
   requires="4.60"
   version="1.0"
   >
<description trim="y">
<![CDATA[
How to use:

IW - Sends INFO WORN and records your clothing

MOVEUP <item> - moves an item up in the order. If you're wearing more than one of that item, you'll need to specify the full item number, i.e. cloak works if there's only one cloak, but for something like rings, you'll need to specify ring12345

MOVEDOWN <item> - moves an item down in the order

SHOWCLOTHES - Lists the current order of your clothes

REWEAR - removes all your clothes and reorders them by placing them in a PACK then taking them out again before wearing everything back again

]]>
</description>

</plugin>


<!--  Get our standard constants -->

<include name="constants.lua"/>

<!--  Triggers  -->

<triggers>
  <trigger
   group="rewear"
   keep_evaluating="y"
   match="^\[\s*[0-9]+\]\s+([A-Za-z'-]+[0-9]+)(.+)$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>table.insert(clothing, "%1")
clothingDetails["%1"] = "%2"</send>
  </trigger>
  <trigger
   group="rewear"
   keep_evaluating="y"
   match="^\s+([a-z\-]+[0-9]+)\s+(.+)$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>table.insert(clothing, "%1")
clothingDetails["%1"] = "%2"</send>
  </trigger>
  <trigger
   group="rewear"
   keep_evaluating="y"
   match="^You are wearing\:$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>clothing = {}
clothingDetails = {}</send>
  </trigger>
  <trigger
   group="rewear"
   keep_evaluating="y"
   match="^\s*n/a\s*([A-Za-z'-]+[0-9]+)(.+)$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>table.insert(clothing, "%1")
clothingDetails["%1"] = "%2"</send>
  </trigger>
  <trigger
   group="rewear"
   keep_evaluating="y"
   match="^([0-9]+)h,\s+([0-9]+)m\s+([a-z]+)\-$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>EnableTriggerGroup("rewear", false)</send>
  </trigger>
</triggers>

<!--  Aliases  -->

<aliases>
  <alias
   match="^iw$"
   enabled="y"
   regexp="y"
   send_to="12"
   ignore_case="y"
   keep_evaluating="y"
   sequence="100"
  >
  <send>Send("info worn")
EnableTriggerGroup("rewear", true)</send>
  </alias>
  <alias
   match="^ShowClothes$"
   enabled="y"
   regexp="y"
   send_to="12"
   ignore_case="y"
   keep_evaluating="y"
   sequence="100"
  >
  <send>ShowClothes()</send>
  </alias>
  <alias
   match="^moveup ([A-Za-z0-9'-]+)$"
   enabled="y"
   regexp="y"
   send_to="12"
   ignore_case="y"
   keep_evaluating="y"
   sequence="100"
  >
  <send>MoveUp("%1")</send>
  </alias>
  <alias
   match="^movedown ([A-Za-z0-9'-]+)$"
   enabled="y"
   regexp="y"
   send_to="12"
   ignore_case="y"
   keep_evaluating="y"
   sequence="100"
  >
  <send>MoveDown("%1")</send>
  </alias>
  <alias
   match="^rewear$"
   enabled="y"
   regexp="y"
   send_to="12"
   ignore_case="y"
   keep_evaluating="y"
   sequence="100"
  >
  <send>Rewear()</send>
  </alias>
</aliases>

<!--  Script  -->


<script>
<![CDATA[
function ShowClothes(thing)
  if clothing then
    Note("----------------------------------------")
    for k, v in ipairs(clothing) do
      if v == thing then
        ColourNote("white", "", v .. clothingDetails[v])
      else
        Note(v .. clothingDetails[v])
      end
    end
    Note("----------------------------------------")
  else
    Note("ReWear: Use IW to list your clothes first.")
  end
end

function Rewear()
  for k, v in ipairs(clothing) do
    Send("remove " .. v)
    Send("put " .. v .. " in pack")
  end
  for k, v in ipairs(clothing) do
    Send("get " .. v .. " from pack")
    Send("wear " .. v)
  end
end

function MoveUp(thing)
  local ada = 1
  for k, v in ipairs(clothing) do
    if string.match(v, thing) then
      ada = k
      thing = v
    end
  end
  if ada > 1 then
    clothing[ada] = clothing[ada-1]
    clothing[ada-1] = thing
  end
  ShowClothes(thing)
end

function MoveDown(thing)
  local ada = #clothing
  for k, v in ipairs(clothing) do
    if string.match(v, thing) then
      ada = k
      thing = v
    end
  end
  if ada < #clothing then
    clothing[ada] = clothing[ada+1]
    clothing[ada+1] = thing
  end
  ShowClothes(thing)
end
]]>
</script>


<!--  Plugin help  -->

<aliases>
  <alias
   script="OnHelp"
   match="Rewear:help"
   enabled="y"
   ignore_case="y"
  >
  </alias>
</aliases>

<script>
<![CDATA[
function OnHelp ()
  world.Note (world.GetPluginInfo (world.GetPluginID (), 3))
end
]]>
</script> 

</muclient>
