Basic usage is to tell your regular script that you want to find an item, then pass along the name of the item (variable) via a subroutine call to the include file. See Concussion macro below for a straightforward example.
------------------------
Hi there,
I'm trying to expand my working knowledge of MQ yet some more (use of an include file, passing parameters from one subroutine to another) and decided to take my working concussion.mac or manarobe.mac and modify them to use an include file for certain repetitive tasks.
The other reason for doing this was that after the most recent MQ2 distribution, I was having some problems with item notification lag. To get around this, I made all of these repetitive tasks do a cyclical check to make sure the state of the window, mouse cursor, etc. was what I need it to be before allowing the script to continue.
Specifically, I viewed those tasks as follows:
find the bag an item is in
open the bag if it isn't already open
grab the item from the bag
close the bag
notify the equipment slot the clicky item can be used in
use item
notify the slot again to equip original item
/autoinv the clicky item
Breaking these tasks down made me realize this would be useful for other stuff too such as coldain ring, jboots, etc.
First, here's a revised concussion.mac:
Code: Select all
|Concussion.mac by Horseshoecrabs
|Useage: This Macro requires Maelin's Pants of Lore
|
|This macro will grab your Maelin's Pants from inventory for those of us not
|wearing them, cast them once, and puts them away.
#include generic_tools.inc
#event StopRoutine "You must be standing to cast a spell."
#event StopRoutine "Your spell is interrupted."
Sub Main(int ConcussionCounter)
/declare BagLegs int outer
/declare IncrementalWait int outer
/declare MyCounter int outer
/declare ConcPants string outer "Maelin's Leggings of Lore"
/declare PriLegs string outer "Merciless Enslaver's Britches"
/call UnloadCursor
/varset BagLegs ${FindItem[${ConcPants}].InvSlot.Pack}
/Call OpenBag ${BagLegs}
/Call GrabItem ${ConcPants}
/Call CloseBag ${BagLegs}
/Call LeftClickSwap Legs ${ConcPants}
/For MyCounter 1 to ${ConcussionCounter}
/cast item ${ConcPants}
/call CastWait
/Next MyCounter
/call LeftClickSwap Legs ${PriLegs}
/call UnloadCursor
/endmac
Sub Event_StopRoutine
/doevents flush
/call LeftClickSwap Legs ${PriLegs}
/call UnloadCursor
/if (${AlreadyMounted}==0) /dism
/endmac
/return
Code: Select all
Sub CastWait
:Casting
/delay ${SpellWait}
/if (${Me.Stunned} && !${Me.Sitting}) /sit
/if (${Me.Stunned}) /goto :Casting
/if (${Me.Casting.ID}) /goto :Casting
/return
Sub CloseBag(BagToClose)
:CloseBagWait
/if (${BagToClose}) {
/if (${Window[${InvSlot[${BagToClose}].Name}].Open}) {
/nomodkey /itemnotify ${InvSlot[${BagToClose}]} rightmouseup
/delay ${IncrementalWait}
/varcalc IncrementalWait ${IncrementalWait}+1
/goto :CloseBagWait
}
}
/varset IncrementalWait 0
/return
Sub GrabItem(ItemToGrab)
:ItemToGrabWait
/if (!${Cursor.ID}) {
/nomodkey /itemnotify ${FindItem[${ItemToGrab}].InvSlot} leftmouseup
/varcalc IncrementalWait ${IncrementalWait}+1
/delay ${IncrementalWait}
/goto :ItemToGrabWait
}
/varset IncrementalWait 0
/return
Sub LeftClickSwap(SlotToSwitch, ItemToWear)
:ItemToSwitchWait
/if (!${Me.Inventory[${SlotToSwitch}].Name.Equal[${ItemToWear}]}) {
/nomodkey /itemnotify ${SlotToSwitch} leftmouseup
/varcalc IncrementalWait ${IncrementalWait}+1
/delay ${IncrementalWait}
/goto :ItemToSwitchWait
}
/varset IncrementalWait 0
/return
Sub OpenBag(int BagToOpen)
:OpenBagWait
/if (${BagToOpen}) {
/if (!${Window[${InvSlot[${BagToOpen}].Name}].Open}) {
/nomodkey /itemnotify ${InvSlot[${BagToOpen}]} rightmouseup
/delay ${IncrementalWait}
/varcalc IncrementalWait ${IncrementalWait}+1
/goto :OpenBagWait
}
}
/varset IncrementalWait 0
/return
Sub UnloadCursor
:loop
/autoinv
/delay ${IncrementalWait}
/if (${Cursor.ID}) {
/varcalc IncrementalWait ${IncrementalWait}+1
/goto :loop
}
/varset IncrementalWait 0
/return
/if invslot[$BagLegs} is a container /do this
/if invslot[$BagLegs} is an open container /do this
Instead, I am having to make a new variable, make it equal to ${BagLegs}-21, and then use the Pack function. For purposes of aesthetics, can I do it the way I want? If so, how?
The thing that's got me stymied is that I can use the ${BagLegs} variable to send a successful /itemnotify to open and close the bag, but I just can't figure out how to check to see if it is a bag (or it's open/close state) in the first place.
http://www.macroquest2.com/wiki/index.p ... m#Examples
It also occurred to me that SelectedItem TLO may be the correct function to use but I'm not sure. The link above now has information copied into it from the html documenation.
And if it's EBS that answers, please note that I do have quotation marks around my declared variables above until I can iron out a completely different bug.
Thanks!

