This site makes extensive use of JavaScript.
Please enable JavaScript in your browser.
Live
PTR
10.2.7
PTR
10.2.6
Beta
Equipment Switching
Post Reply
Return to board index
Post by
Gonjero
Hi I have a macro here which i was using to teleport with cloak of coordination which equips the cloak and teleports me and then re-equips the previous cloak (the one with the higher level)
/run local c,e,t=65274,GetInventoryItemID(“player”,15)t=GetItemCooldown©>0 if c==e then if COC_PREVEQ and t then EquipItemByName(COC_PREVEQ)COC_PREVEQ=nil end elseif not t then COC_PREVEQ=e and GetItemInfo(e)EquipItemByName©end
/use 15
FYI I have no idea about how to write macro codes in wow and I am not the one who wrote the code above but I have read about the macros and tried to make a macro with the same idea but in a different way and for a different purpose, what i am trying to do is to make a macro that equips a defined item like (deepdive helmet) then when I click it again it will re-equip the previous item.
Does anyone have any idea if its possible and how, and thanks in forward.
Post by
Nulgar
Well, that's not just a macro, but actual Lua code inside that macro, which makes it less obvious to understand unless you already have coding experience.
A quick crash course how to modify that macro for another item:
The number 65274 refers to the itemID of
Cloak of Coordination
, you can find out the ID of an item by looking it up on Wowhead and checking the page address for what number comes after "item=".
There's also the slot number of the back slot, 15, which is used twice in the macro. See
this page
for a list of slot numbers. You mention a head item,
Deepdive Helmet
, that would be slot 1.
If you do use more than one macro of that kind, you also have to adjust the name of the variable that holds the previously equipped item, COC_PREVEQ. It seems the "COC" stands for the cloak, so you could use DDH_PREVEQ for the Deepdive Helm macro.
However, unless you're using several macros for the same slot, you may also simply append the slot number, so PREVEQ15 for the cloak macro above, or PREVEQ1 for a head slot macro.
Lastly, I suggest inserting the line #showtooltip at the start of each macro, and using the Question Mark icon (should be the very first one)
This way, the macro automatically the icon of the first item (or spell) it would use, which in this case means it shows the icon of the currently equipped item in the relevant slot.
I might as well, for the Deepdive Helm I propose:
/run local c,e,t=10506,GetInventoryItemID(“player”,1)t=GetItemCooldown(c)>0 if c==e then if DDH_PREVEQ and t then EquipItemByName(DDH_PREVEQ)DDH_PREVEQ=nil end elseif not t then DDH_PREVEQ=e and GetItemInfo(e)EquipItemByName(c)end
/use 1
Disclaimer:
this was all written on a smartphone, I didn't test anything ingame.
Post by
Gonjero
Thanks for your time and effort Nulgar,
now I have a better idea on what the code actually is, so from what I have read, it will work depending on the if statement (if the item was on cooldown or not) so i guess as the helmet has no ability to be used so it will not be on cooldown, and btw i figured out if i changed the /use to /equip but what should be after the /equip ? is it possible to use the variable names above to refer to the items?
Post by
quthar
Since the item has no cooldown you can leave out all the stuff dealing with the cooldown.
There's no need for /equip. The call to
EquipItemByName()
handles that.
/run local c,e=10506,GetInventoryItemID('player',1)if c==e and DDH_PREVEQ then EquipItemByName(DDH_PREVEQ)DDH_PREVEQ=nil else DDH_PREVEQ=e and GetItemInfo(e)EquipItemByName(c)end
Here's my lua code expanded for readability:
local itemID = 10506
local equippedID = GetInventoryItemID('player',1)
if itemID == equippedID then
EquipItemByName(DDH_PREVEQ)
DDH_PREVEQ = nil
else
DDH_PREVEQ = equippedID
EquipItemByName(itemID)
end
Post by
Gonjero
Since the item has no cooldown you can leave out all the stuff dealing with the cooldown.
There's no need for /equip. The call to
EquipItemByName()
handles that.
/run local c,e=10506,GetInventoryItemID('player',1)if c==e and DDH_PREVEQ then EquipItemByName(DDH_PREVEQ)DDH_PREVEQ=nil else DDH_PREVEQ=e and GetItemInfo(e)EquipItemByName(c)end
Here's my lua code expanded for readability:
local itemID = 10506
local equippedID = GetInventoryItemID('player',1)
if itemID == equippedID then
EquipItemByName(DDH_PREVEQ)
DDH_PREVEQ = nil
else
DDH_PREVEQ = equippedID
EquipItemByName(itemID)
end
Thanks ALOT !
its working smoothly and kinda very helpful i will post the code you made there on that item page, hope it helps more people than spending time searching for their helmets or keep saving their set equipment.
Post by
Nulgar
i figured out if i changed the /use to /equip but what should be after the /equip ? is it possible to use the variable names above to refer to the items?
No, the /use is to actually use the cloak which was equipped with the statement above. Didn't look
too
much at the helm (it was late :D) so I didn't notice it doesn't have a Use effect. As quthar said, there's no need for the /use command in that case.
And no, you can't use the variables outside a /run statement. In regular macro commands, you can only use item names or IDs, or equipment/inventory slot IDs.
As inspiration, here's a macro I use for
Dragonwrath, Tarecgosa's Rest
that doesn't involve Lua code, but requires me to right-click the macro to equip the previous weapon, which is presumed to be located in the former inventory slot of Dragonwrath:
#showtooltip 16
/equip Dragonwrath, Tarecgosa's Rest
/use Dragonwrath, Tarecgosa's Rest
/equip 4 2
Show the weapon slot. On left-click equip Dragonwrath, then on second click use it. On right-click, equip the item in the 2nd slot of bag 4 (the left-most one, the backpack itself is bag 0) which is where Dragonwrath sits otherwise.
Post by
Gonjero
i figured out if i changed the /use to /equip but what should be after the /equip ? is it possible to use the variable names above to refer to the items?
No, the /use is to actually use the cloak which was equipped with the statement above. Didn't look
too
much at the helm (it was late :D) so I didn't notice it doesn't have a Use effect. As quthar said, there's no need for the /use command in that case.
And no, you can't use the variables outside a /run statement. In regular macro commands, you can only use item names or IDs, or equipment/inventory slot IDs.
As inspiration, here's a macro I use for
Dragonwrath, Tarecgosa's Rest
that doesn't involve Lua code, but requires me to right-click the macro to equip the previous weapon, which is presumed to be located in the former inventory slot of Dragonwrath:
#showtooltip 16
/equip Dragonwrath, Tarecgosa's Rest
/use Dragonwrath, Tarecgosa's Rest
/equip 4 2
Show the weapon slot. On left-click equip Dragonwrath, then on second click use it. On right-click, equip the item in the 2nd slot of bag 4 (the left-most one, the backpack itself is bag 0) which is where Dragonwrath sits otherwise.
Thanks for your effort and inspiration Nulgar, looks like using the bag slot location will be much more easier and more practical for my future macros :)
but I still have much more to learn, looks like I will be hanging around these forums more often :P
thanks again.
Post by
Gonjero
I am having an issue with this macro
/run local c,e=133755,GetInventoryItemID('player',16)if c==e and DDH_PREVEQ then EquipItemByName(DDH_PREVEQ)DDH_PREVEQ=nil else DDH_PREVEQ=e and GetItemInfo(e)EquipItemByName(c)end
which is used for the underlight angler, I did not have any issue while using it with my retribution paladin because it switches between a 2 handed weapon and a fishing pole which is also 2 handed but am having this issue with my rogue, what happens when I first time press the macro it equips the fishing pole but after that when I press it again it equips the main hand weapon in the off hand slot and later when I press the macro again it equips the fishing pole, and again when I run it, it will not do anything as it is not working, I tried to figure it out alone so I tried these:
/run local c,e=133755,GetInventoryItemID('player',16),GetInventoryItemID('player',17)if c==e and DDH_PREVEQ then EquipItemByName(DDH_PREVEQ)DDH_PREVEQ=nil else DDH_PREVEQ=e and GetItemInfo(e)EquipItemByName(c)end
/run local c,e=133755,GetInventoryItemID('player',16),('player',17)if c==e and DDH_PREVEQ then EquipItemByName(DDH_PREVEQ)DDH_PREVEQ=nil else DDH_PREVEQ=e and GetItemInfo(e)EquipItemByName(c)end
I tried hard to understand how can I make this work but it seems that I should seek someone to help me with this...
Post Reply
You are not logged in. Please
log in
to post a reply or
register
if you don't already have an account.