Version 1.7 of ItemRack introduces event-driven scripts to swap gear. 1.9 changes several essential parts of event creation, which this page will cover.
The intent is to have users scripting the events. They are just like macros, they use the exact language for everything that comes after a /script in a macro, except they run in response to game events. (Note: Language applies both to the scripting language and the human language. While this mod tries to be locale-independent in the bar and sets, it can't hope to ever be locale-independent for events and won't even try.)
In the options window when you right-click the minimap button are three tabs. All event setup is done in the Events tab.
Events are disabled initially. To begin using events you need to enable it with the "Enable Events" checkbox at the top of the Events tab. This is the "master switch". You can set up a key binding to toggle all events on or off as well.
In that tab you'll see a list of events with a red question mark beside it. Click the question mark to choose what set to equip for the event. When you've chosen a set it will be enabled. You won't be able to enable an event until you've associated a set for it. (even if the event script doesn't rely on a defined script)
To disable/enable a set with an associated event, uncheck the event. Alternately, you can click Delete to remove the set association and have it drop down to the bottom of the list.
Deleting an event not associated with a set will completely remove it if no other characters use that event.
Editing or Creating Events
If you hit Edit or New at the bottom of the events tab you'll be brought to the event script editor. Here you define when the event runs and what it does. You can copy-paste into/out of these boxes. The four boxes are:
Name: This is the name you'll see in the event list, ie Mount, Warrior:Berserker, Swimming, etc.
Trigger: This is the WoW-generated event you want the event to trigger from. ie PLAYER_AURAS_CHANGED, CHAT_MSG_COMBAT_SELF_HITS, etc
Delay: This is the time, in seconds, after the last occurance of the Trigger before the script runs.
Script: This is the actual script that runs. You can use any lua construct or make it as complicated as you want. The code is directly run without any parsing.
Some knowledge of WoW Lua and scripting will help a great deal in editing and creating events. An excellent resource is the wiki: http://www.wowwiki.com/Interface_Customization
In the lower left is a Test button. You can use this to run the script once to make sure there are no syntax or other obvious errors. But it can't test if the trigger works or anything beyond stuff that would prompt a red error box.
If at any time you've messed up your default events and want them back: /itemrack reset events. This will not touch your custom events. It will just recreate the default events.
Example of creating an event
Let's make an event to equip a shield when we're targeting a mana user. This would only be useful for warriors under 30 but the principles will apply to almost event event you make.
First, make a set called 'Shield' that contains just a shield in the offhand slot and a weapon in mainhand slot. We'll equip this set when we target a mana user and unequip it when our target drops or changes to someone without mana.
The first step is to identify when you want to check the event. In this case, PLAYER_TARGET_CHANGED is a likely one. (Some may remember UNIT_AURA firing when changing targets, this is no longer true)
PLAYER_TARGET_CHANGED often fires in pairs, once to untarget and again to target. These pairs happen instantly so we'd probably want to wait until they're done. We don't want to unequip a shield and equip a shield within 0.01 seconds. So let's give it a delay of 0.5. You can make it 0.25 also.
Now we need to know how to find out if the target is a mana user. The UnitPowerType function will give us just that. If UnitPowerType("target")==0 then they have a "blue" mana bar.
To put it together:
name: Shield Bash
if UnitPowerType("target")==0 then
--[[Equips a set when targeting a mana user]]
Now associate the set "Shield" with the "Shield Bash" event and you're done!
0.5 seconds after a PLAYER_TARGET_CHANGED pair, it will check if your target has a mana bar, and equip the associate set ("Shield") if so. If not, it will unequip the set to whatever you wore previously.
Note: LoadSet is an awkward name based on the 1.7-1.8 versions of ItemRack, when a SaveSet() was needed to store slots. It will likely get a pseudonym in the future of UnequipSet().
For a thread discussing events and how to create them, feel free to post here: ItemRack - Events.