Code: Select all
objectdef PackHandler
{
method TogglePack(int myPackID)
{
if ${InvSlot[${myPackID}].Item.Container}
nomodkey EQItemNotify ${myPackID} RightMouseUp
}
member IsOpen(myPackID)
{
return ${Window[${InvSlot[${myPackID}].Name}].Open}
}
function OpenPack(int myslot)
{
if ${InvSlot[${myslot}].Pack}
myslot:Set[${InvSlot[${myslot}].Pack}]
elseif (${InvSlot[$myslot}].Item.Container} == 0)
return FALSE
if !${This.IsOpen[${myslot}]}
{
This:TogglePack[${myslot}]
wait 10 ${This.IsOpen[${myslot}]}
Wait 1
}
}
function ClosePack(int myslot)
{
if ${InvSlot[${myslot}].Pack}
myslot:Set[${InvSlot[${myslot}].Pack}]
elseif (${InvSlot[$myslot}].Item.Container} == 0)
return FALSE
if ${This.IsOpen[${myslot}]}
{
This:TogglePack[${myslot}]
wait 10 !${This.IsOpen[${myslot}]}
Wait 1
}
}
}
I wrote this, but it works strictly off ID numbers, not slot names.
I use that object with this one:
Code: Select all
objectdef ItemHandler inherits PackHandler
{
variable string Name
variable int ID
variable int oldSlot
variable int tempSlot
method Initialize(string myname,int myslot)
{
Name:Set[${myname}]
ID:Set[${FindItem[=${myname}].ID}]
if !${myslot}
tempSlot:Set[29]
else
tempSlot:Set[${myslot}]
}
member PackID=${FindItem[=${This.Name}].InvSlot.Pack}
member Stackable=${FindItem[=${This.Name}].Stackable}
member CastTime=${FindItem[=${This.Name}].CastTime}
member Pack=${FindItem[=${This.Name}].InvSlot.Pack.Name}
member Slot=${FindItem[=${This.Name}].InvSlot}
member Count=${FindItemCount[=${This.Name}]}
member IsPackOpen=${Window[${This.Pack}].Open}
method LeftClick(myslot,mymod)
{
if !${myslot}
myslot:Set[${This.Slot}]
if !${mymod.Length}
mymod:Set[nomodkey]
else
mymod:Set[${mymod] nomodkey]
Execute "${mymod} EQItemNotify ${myslot} LeftMouseUp"
}
method RightClick(myslot)
{
if !${myslot}
myslot:Set[${This.Slot}]
nomodkey EQItemNotify ${myslot} RightMouseUp
}
function PickUp(string qty)
{
variable string mod
if ${Cursor.ID}
return FALSE
Switch ${qty}
{
case ctrl
case single
case 1
mod:Set[ctrl]
break
case 20
case all
case stack
case shift
mod:Set[shift]
break
default
if ${This.Stackable}
mod:Set[ctrl]
}
oldSlot:Set[${This.Slot}]
call This.CursorToggle ${This.Slot} ${mod}
}
function PutDown(int destSlot)
{
if ${Cursor.ID} != ${This.ID}
return FALSE
if !${destSlot}
destSlot:Set[${This.oldSlot}]
call This.CursorToggle ${destSlot}
}
function CursorToggle(int myslot,string mymod)
{
if !${myslot}
myslot:Set[${This.Slot}]
if !${myslot}
myslot:Set[${This.oldSlot}]
variable int OldCursorID=${Cursor.ID}
call This.OpenPack ${myslot}
This:LeftClick[${myslot},${mymod}]
wait 50 (${OldCursorID} != ${Cursor.ID}
call This.ClosePack ${myslot}
}
function MoveTo(string myslot,string mymod)
{
call This.PickUp ${mymod}
call This.PutDown ${myslot}
}
function Activate()
{
if ${This.Busy}
return FALSE
variable bool SwapFlag=FALSE
if (${Cursor.ID} || ${This.Count}==0)
return FALSE
if ${This.Slot} > 29
SwapFlag:Set[TRUE]
if ${SwapFlag}
call This.MoveTo ${tempSlot}
This:RightClick
if ${This.CastTime}
{
Wait 10 ${Me.Casting.ID}
while ${Me.Casting.ID}
WaitFrame
}
if ${SwapFlag}
{
if ${Cursor.ID} && ${InvSlot[${tempSlot}].Item.ID}== ${This.ID}
call This.CursorToggle ${tempSlot}
call This.PutDown ${oldSlot}
}
}
member:bool Busy()
{
if ( ${Cursor.ID} || ${Me.Casting.ID} || ${Window[MerchantWnd].Open} || ${Window[SpellBookWnd].Open} || ${Window[TradeWnd].Open} || ${Window[BigBankWnd].Open} || ${Window[BankWnd].Open} || ${Window[LootWnd].Open} )
return TRUE
else
return FALSE
}
}
to handle my items.
Granted, this is only until I add a real InvSlot:MoveTo method to the source, but this gets me by for now.
e.g.
Code: Select all
function main()
{
declare myitem ItemHandler script "Iron Ration"
call myitem.Activate
}
Would find an item named "Iron Ration" in your inventory, check to make sure none of the windows listed in the Busy function are open, and check your cursor for items, then it would swap it (defaulting to one item if stackable) to its tempslot (defaults to pack8, can be set with 2nd parameter in declare), if its an item clicky, it'll wait for the item to finish casting before swapping it back.