<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Monday, December 24, 2010, 3:06 AM -->
<!-- MuClient version 4.40 -->

<!-- Plugin "Give_All" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Give_All"
   author="Abelinc"
   id="a1e6204a17f21f6d51860bbb"
   language="Lua"
   purpose="Intercepts 'give all', only gives all non-kept items"
   date_written="2010-12-24 03:06:52"
   requires="4.33"
   version="1.0"
   >
<description trim="y">
<![CDATA[
intercepts 'give all'. If you have any kept items, turns the command into one
which only gives non-kept items. Does NOT affect give all.item
]]>
</description>
</plugin>


<!--  Get our standard constants -->

<include name="constants.lua"/>

<!--  Triggers  -->

<triggers>
  <trigger
   group="dogive"
   keep_evaluating="y"
   match="givedone"
   omit_from_output="y"
   script="givedone"
   sequence="100"
  >
  </trigger>
  <trigger
   group="invdatastart"
   match="{/invdata}"
   omit_from_output="y"
   script="invdataend"
   sequence="100"
  >
  </trigger>
  <trigger
   group="invdatastart"
   match="{invdata}"
   omit_from_output="y"
   script="invdatastart"
   sequence="100"
  >
  </trigger>
  <trigger
   group="invdatacap"
   match="^(?P&lt;idnum&gt;\d*)\,(?P&lt;flags&gt;\w*)\,(.*?)\,(\d+)\,(\d+)\,(\d)\,(-?\d+)\,(-?\d+)$"
   omit_from_output="y"
   regexp="y"
   script="makelist"
   sequence="100"
  >
  </trigger>
</triggers>

<!--  Aliases  -->

<aliases>
  <alias
   script="giveall"
   match="give all *"
   enabled="y"
   sequence="100"
  >
  </alias>
</aliases>

<!--  Script  -->


<script>
<![CDATA[
itemlist={}
Note(GetPluginInfo(GetPluginID(), 3))

function giveall(name, line, wildcards)
	if (wildcards[1]) then
		tempdelay = GetSpeedWalkDelay()
		SetSpeedWalkDelay(125)
		givetarget = wildcards[1]
		SendNoEcho("invdata")
		EnableTriggerGroup("invdatastart", true)
	else
		Note("Who are you trying to give all to?")
    end
end

function makelist(name, line, wildcards)
  itemlist[tostring(wildcards["idnum"])]=wildcards["flags"]
end

function invdatastart(name, line, wildcards)
  itemlist={}
  EnableTriggerGroup("invdatacap", true)
end

function invdataend(name, line, wildcards)
	EnableTriggerGroup("invdatacap", false)
	EnableTriggerGroup("invdatastart", false)
	startgive()
end

function startgive()
  EnableTriggerGroup("dogive", true)
  for id, flags in pairs(itemlist) do
    if not string.match(flags, "K") then
      Queue("give "..id.." "..givetarget, false)
    end
  end
  Queue("echo givedone", false)
end

function givedone(name, line, wildcards)
  EnableTriggerGroup("dogive", false)
  SetSpeedWalkDelay(tempdelay)
end
]]>
</script>


</muclient>
