Page 1 of 2

Need help with Macros

PostPosted: Fri Dec 25, 2015 4:45 pm
by Waterflame
I have started doing macros but the information about the commands for 1.12.1 isn't that much and for some reason most of it doesn't work when I try on Nostalrius (PvP realm).

If anyone can help, I need macros for:
1) Cast a buff (for example: Blessing of Might) when I don't have it casted (not just /cast Blessing of Might but checking first).
2) Untarget (I have tried /cleartarget and it doesn't work).
3) Target nearest enemy (you can do /target and then the name but that's not what I want).
4) Heal (/cast Holy Light) if health is lower than (for example 80) and/or if health is lower than (for example 20%).

I will remember more but first I wanna see if anyone can answer this because I'm sure that if anyone do it I will try the command and it won't work (I hope not). I will try to answer about the result.

Type '/help' for a listing of a few commands. :| -Waterflame

Re: Need help with Macros

PostPosted: Fri Dec 25, 2015 8:36 pm
by cyklon
1). /script if(UnitClass("target")=="Warrior" or UnitClass("target")=="Rogue") and not buffed("Blessing of Might", 'target') then CastSpellByName("Blessing of Might") end;
4). /script if UnitHealth("target")/UnitHealthMax("target") < 0.8 then CastSpellByName("holyspell") else CastSpellByName("holyspell") end;


should work if you have supermacro addon.

Re: Need help with Macros

PostPosted: Sat Dec 26, 2015 12:38 am
by Waterflame
cyklon wrote:1). /script if(UnitClass("target")=="Warrior" or UnitClass("target")=="Rogue") and not buffed("Blessing of Might", 'target') then CastSpellByName("Blessing of Might") end;
4). /script if UnitHealth("target")/UnitHealthMax("target") < 0.8 then CastSpellByName("holyspell") else CastSpellByName("holyspell") end;


should work if you have supermacro addon.

When I first tried it wasn't working but then I saw that I needed the Super Macro Addon so I searched for it and found it on the Addon Pack on the Nostalrius's site. After installing it I tried out and after some changes, it worked the first one:
Code: Select all
/script if not buffed("Blessing of Might") then CastSpellByName("Blessing of Might") end
but the fourth one didn't worked. By searching how to fix it I saw that you tooked the code from here: http://wowwiki.wikia.com/wiki/Useful_macros_(1.0)

You helped but I still don't know how to do the last 3 macros, I can't find a list of working macro commands for 1.12.1 anywhere. It's like, the codes aren't written anywhere, people just know them (some of them).

Re: Need help with Macros

PostPosted: Sat Dec 26, 2015 12:40 am
by Dreez
without supermacro:
1).
Code: Select all
/run local v=0 i=1 while UnitBuff("target", i)do d=UnitBuff("target", i)if d=="Interface\\Icons\\Spell_Nature_Lightning"then v=1 end i=i+1 end if(v==0)then CastSpellByName("Innervate")end
-- edited out some conditions I used for an other macro
you will have to change the spelltexture (in this case Spell_Nature_Lightning) to whatever buff you're looking for, either get the name from the internet or use this macro:
Code: Select all
/run for i=1,16 do local B=UnitBuff("target",i); if B then ChatFrame1:AddMessage(B) end end

2).
Code: Select all
/run ClearTarget()

3).
Code: Select all
/run TargetNearestEnemy()

4.) as described by cyklon -- edited below
Code: Select all
/script if (UnitHealth("target")/UnitHealthMax("target")<0.8) then CastSpellByName("holyspell") else CastSpellByName("holyspell") end

exchange the "holyspell" by the spellname you want to cast ofc

Re: Need help with Macros

PostPosted: Sat Dec 26, 2015 12:53 am
by Dreez
actually this is more what you're looking for:
4.)
Code: Select all
/run local c=CastSpellByName u=UnitHealth('target')m=UnitHealthMax('target')if(u/m<0.2)then c("Holy Light")elseif(u/m<0.8)then c("Flash of Light")end

casts Holy light if target is below 20%, casts Flash of Light if target is below 80%

Re: Need help with Macros

PostPosted: Sat Dec 26, 2015 2:12 am
by Waterflame
Dreez wrote:without supermacro:
1).
Code: Select all
/run local v=0 i=1 while UnitBuff("target", i)do d=UnitBuff("target", i)if d=="Interface\\Icons\\Spell_Nature_Lightning"then v=1 end i=i+1 end if(v==0)then CastSpellByName("Innervate")end
-- edited out some conditions I used for an other macro
you will have to change the spelltexture (in this case Spell_Nature_Lightning) to whatever buff you're looking for, either get the name from the internet or use this macro:
Code: Select all
/run for i=1,16 do local B=UnitBuff("target",i); if B then ChatFrame1:AddMessage(B) end end

2).
Code: Select all
/run ClearTarget()

3).
Code: Select all
/run TargetNearestEnemy()

4.) as described by cyklon -- edited below
Code: Select all
/script if (UnitHealth("target")/UnitHealthMax("target")<0.8) then CastSpellByName("holyspell") else CastSpellByName("holyspell") end

exchange the "holyspell" by the spellname you want to cast ofc

The 2) and the 3) works but the 1) and the 4) don't.
I used the code:
Code: Select all
/run for i=1,16 do local B=UnitBuff("player",i); if B then ChatFrame1:AddMessage(B) end end
to figure the name "Interface\Icons\Spell_Holy_FistOfJustice" and changed the cast code Innervate to Blessing of Might but there's still something wrong on the code:
Code: Select all
/run local v=0 i=1 while UnitBuff("target", i)do d=UnitBuff("target", i)if d=="Interface\Icons\Spell_Holy_FistOfJustice"then v=1 end i=i+1 end if(v==0 and UnitPowerType("target")==0 and UnitIsPlayer("target"))then CastSpellByName("Blessing of Might")end
I tried so many ways to change the code but couldn't figure it out. Please confirm it and try to change the target to player.
This next code is one of my tries to confirm if the code could work:
Code: Select all
/run for i=1,16 do local B=UnitBuff("player",i); if B then CastSpellByName("Holy Light") else CastSpellByName("Blessing of Might") end end

To fix the problem do this code:
Code: Select all
/run for i=1,16 do local B=UnitBuff("player",i); if B then CastSpellByName("Blessing of Might") end end
but so that "if B then" cast and get off the loop for. This last code does what I want but reversed (when I have Blessing of Might it casts and when I don't it doesn't). It's not just put if not instead of if because the loop ruins it all.
I'm too confused to explain it :?:

Re: Need help with Macros

PostPosted: Sat Dec 26, 2015 2:26 am
by Waterflame
Dreez wrote:actually this is more what you're looking for:
4.)
Code: Select all
/run local c=CastSpellByName u=UnitHealth('target')m=UnitHealthMax('target')if(u/m<0.2)then c("Holy Light")elseif(u/m<0.8)then c("Flash of Light")end

casts Holy light if target is below 20%, casts Flash of Light if target is below 80%

I edited this post because I was wrong, the 4) is working perfectly too! :D
But I still prefer to use player instead of target...

Re: Need help with Macros

PostPosted: Sat Dec 26, 2015 10:46 am
by Dreez
to make the first work please check my edited post (I accidently left some conditions in there which I used for an other macro)
this is what you're looking for
Code: Select all
/run local v=0 i=1 while UnitBuff("target", i)do d=UnitBuff("target", i)if d=="Interface\\Icons\\Spell_Holy_FistOfJustice"then v=1 end i=i+1 end if(v==0)then CastSpellByName("Blessing of Might")end

Re: Need help with Macros

PostPosted: Mon Dec 28, 2015 5:01 pm
by Waterflame
Dreez wrote:to make the first work please check my edited post (I accidently left some conditions in there which I used for an other macro)
this is what you're looking for
Code: Select all
/run local v=0 i=1 while UnitBuff("target", i)do d=UnitBuff("target", i)if d=="Interface\\Icons\\Spell_Holy_FistOfJustice"then v=1 end i=i+1 end if(v==0)then CastSpellByName("Blessing of Might")end

The code works, I was just writting right now that the code wasn't working but then I remembered that you use target instead of player so I tried again with me targeted and it works. Thanks ;)

Re: Need help with Macros

PostPosted: Mon Dec 28, 2015 10:29 pm
by Waterflame
I have another question (AddOn related):
In the chat, if I writte:
Code: Select all
/run ChatFrame1:AddMessage(UnitLevel("player"))
or
Code: Select all
/script ChatFrame1:AddMessage(UnitLevel("player"))
it will writte the player's level in the chat, but, if I try
Code: Select all
ChatFrame1:AddMessage(UnitLevel("player"))
on the .lua document for an AddOn, it always writtes 0.