Need a little help for macro command.

Need a little help for macro command.

by Myskillkills » Tue Feb 16, 2016 8:47 pm

Hey.
I've got a macro that use one item if the other one is on cooldown.
Lets say, I've got anti-venom and elixir of poison resistance, and if the first one is on cooldown, that it will use elixir. But theres a bad thing about that one, since you need to put specific items in the specific slots to make it working, look:

/script if GetContainerItemCooldown(4,1)>1 then UseContainerItem(4,2) else TargetUnit("player");UseContainerItem(4,1);TargetUnit("playertarget") end

So, lets say I've got that addon from our forums (ClassicMacros) which allows me to make a macro with /use command, without naming a specific slot in the specific bag to use.
How can it look like? To check if the item is on cooldown without naming a specific one (bag, slot), or its not possible?
Also, I do believe theres no possibility to change that command which checks if the item is on cooldown and ready to be used or not, so I'll have to put specific items in the specific slots and in the specific bags to make the macro working, but is there a possibility to change it the way /use command works?

Ty you in advance!
User avatar
Myskillkills
Senior Sergeant
Senior Sergeant
 

Re: Need a little help for macro command.

by AfterAfterlife » Wed Feb 17, 2016 12:48 am

Well, I'm taking that Vanilla doesn't have "UseItemByName" and "GetItemCooldown"...so my guess is:
- Search for an item with the name: "Anti-Venom" in your bags
- Checks if it's in CD
- If not, use it. Else, search for "Elixir of Poison Resistance" and use that instead.

I'll add a piece of code in a sec.

Edit:

Code: Select all
function useItem()
   for i=0, 4 do
      for j=1, GetContainerNumSlots(i) do
         if string.find(select(7, GetContainerItemInfo(i,j), "Anti-Venom") and GetContainerItemCooldown(i,j) )) == 0 then
            TargetUnit("player");
            UseContainerItem(i, j);
            TargetUnit("playertarget");
            return;
         end
      end
   end
   for i=0, 4 do
      for j=1, GetContainerNumSlots(i) do
         if string.find(select(7, GetContainerItemInfo(i,j), "Elixir of Poison Resistance") and GetContainerItemCooldown(i,j) )) == 0 then
            UseContainerItem(i, j);
            return;
         end
      end
   end
end


There are room for improvement, like moving both items to bag#1, jump to the next for if it's in CD, saving the slot of Elixir if you find it while searching for Anti-Venom, etc...
Still, this should work, didn't test it though.
AfterAfterlife
Grunt
Grunt
 

Re: Need a little help for macro command.

by Myskillkills » Wed Feb 17, 2016 6:01 am

Looks so complicated :D

I'll check that one and tell you how it works!
User avatar
Myskillkills
Senior Sergeant
Senior Sergeant
 

Re: Need a little help for macro command.

by AfterAfterlife » Wed Feb 17, 2016 1:44 pm

Myskillkills wrote:Looks so complicated :D

I'll check that one and tell you how it works!


If there is an addOn that lets you exceed 255 characters in a macro, just copy&paste the code above (without the first and last line, i.e. "function useItem()" and "end").

If not, you can always make a super, simple addOn that only contains that piece of code. Then you can call functions from lua files (addOns), simply add the name of the function. E.g.: "/script useItem()"
AfterAfterlife
Grunt
Grunt
 

Re: Need a little help for macro command.

by slipryy » Thu Feb 18, 2016 1:08 am

/script if GetItemCooldown("Anti-Venom")>1 then UseItemByName("Elixir of Poison Resistance") else UseItemByName("Anti-Venom") end
slipryy
Senior Sergeant
Senior Sergeant
 


Return to Addons & macros