I think it kind of depends on the particulars of what exactly you want it to do.
The detection part can be done like:
/script if GetItemInfo(GetInventoryItemID("player", 17) or 0) == "Skull of Impending Doom" then print("A") else print("B") end
Or, if you’re ok using ItemID numbers instead of names:
/script if GetInventoryItemID("player", 17) == 4984 then print("A") else print("B") end
The number 17 refers to the off-hand inventory slot. Both those commands just print A or B in chat depending on the Skull of Impending Doom currently being equipped.
Obviously you want to do something other than just print to chat.
You could use the equipment manager as backend. Assuming you have 2 sets stored, called “My Tankset” and “My Healset”, you could load them like:
/script C_EquipmentSet.UseEquipmentSet(C_EquipmentSet.GetEquipmentSetID(((GetItemInfo(GetInventoryItemID("player", 17) or 0) == "Skull of Impending Doom") and "My Tankset" or "My Healset")))
Or if you want to swap a single item:
/script EquipItemByName(((GetItemInfo(GetInventoryItemID("player", 17) or 0) == "Skull of Impending Doom") and "Some other item" or "Skull of Impending Doom"))
Hey, thank you for the response. Scripts are a bit beyond my knowledge, why I tried to create a solution using weapon type. I should probably have specified what I intended to do with the macro.
What I have right now:
Main Hand: Perdition’s Blade
Off Hand: Core Hound Tooth
What I want to do with one macro is to equip Skull of Impending Doom into the Off Hand when using the macro, and then switch back to Core Hound Tooth when using the macro again.
Your latest one for single item works one way, but not for the return trip - since it keeps the skull in Off Hand and instead puts Core Hound Tooth in main hand (replacing Perdition’s Blade). Is it possible to specify which slot the Core Hound Tooth goes into? (17)
EquipItemByName can take the slot as second argument, so the final example from my previous post then becomes:
/script EquipItemByName(((GetItemInfo(GetInventoryItemID("player", 17) or 0) == "Skull of Impending Doom") and "Core Hound Tooth" or "Skull of Impending Doom"), 17)
That said, i hadn’t really realized before your reply that it was a weapon-specific macro (besides the conditional itself), and because of that kinda assumed it would be used out of combat, as you can’t switch equipment while in combat.
Weapons are obviously the exception to that rule, so i now realize that you probably plan to use it while in combat as well.
EquipItemByName may not behave as desired when in combat. Blizzard changed it’s behaviour (while in combat) at some point during Wrath, in order to prevent rogues using it to switch weapons with different poisons around mid-combat.
Seeing as you’re playing on Classic, i’m not sure if that affects it’s use there or not. I don’t play Classic myself.
If the same protection as on post-WotLK retail exists there, then when using the EquipItemByName-macro while in combat, it will “pick up” the item under your cursor, instead of actually equipping it. You’ll have to try it out to see if that’s the case or not.
If the macro was not ment exclusively for weapons, then i would add a
/stopmacro [combat]
line to the macro (above the /script line) but that’s more for other people that may want to re-use the earlier code examples.
That one sorted the weapon swaps, but as you suspected - it does not work in combat. “Interface action failed because of an AddOn” when attempting to use the macro while in combat. Logged out, disabled all addons, attempted again; same error message. I assume it just calls anything starting with “/script” an AddOn. They stated that WoW Classic was based on the Legion client when it was released, so I would assume a lot, if not all, the same rules are in place.
I recall back in actual vanilla you would have to type out [target=player] rather than just [@player], /cast for any spells rather than just /use. So it definitely operates with more recent rules.
/equip works in combat, but could not find any way to specify the “weapon type” for the off-hand, otherwise I could do something similar which I already do:
Main Hand: Perdition’s Blade (dagger)
Off Hand: Core Hound Tooth (dagger)
then toggle back and forth between the above and:
Main Hand: Thunderfury, Blessed Blade of the Windseeker (sword)
Off Hand: Core Hound Tooth (dagger)
with this macro:
#showtooltip
/equip [equipped:sword]Perdition's Blade;Thunderfury, Blessed Blade of the Windseeker
I’m guessing there’s just no weapon type specification for off-hand items like Skull of Impending Doom, so I’m probably out of luck.
I appreciate the effort you’ve put into this, so thank you for that.
That stopmacro command from earlier would prevent that error from popping up when trying to use the macro in combat, but it wouldn’t cause the command to function.
Ah yea, i was’t aware of that but it makes sense.
Ah, yea if switching the main weapon(type) isn’t a problem then you can work around it quite easily, something like (untested) :
#showtooltip
/equipslot [equipped:sword] 17 Core Hound Tooth; Skull of Impending Doom
/equipslot [equipped:sword] 16 Perdition's Blade; Thunderfury, Blessed Blade of the Windseeker
What I hoped to achieve would be something like this:
/equipslot [equipped:<whatever weapon type Skull of Impending Doom would be>] 17 Core Hound Tooth; Skull of Impending Doom
So that I do not have to alter anything besides the 17th slot which can alternate between the skull and a specified weapon. Not suitable to work around altering the Main Hand at the same time.
I think I’ll just have to settle with 2 different keybinds, but thank you for your time!
Yea, i get it.
The shield has its own type within the [equipped:...] conditional, but plain off-hands do not (as far as i’m aware anyway).
There is one alternative i just thought off though, and i may actually suffice in your particular situation:
/equipslot inventorySlotID bagID slotID
Where inventorySlotID is 17 (for the offhand slot)
and bagID is number 0 to 4 (indicating which of your bags, 0 is backpack)
and slotID is number 1 or higher (indicating which slot within the bag).
As long as you keep the off-hand stored in the same slot (which shouldn’t be a big deal) it’ll keep working. And when it does the switch it automaticly puts the previous off-hand item in the same slot by default.