Thread Tools Display Modes
05-27-18, 12:17 PM   #1
Xancepants
A Deviate Faerie Dragon
Join Date: Oct 2014
Posts: 17
Question about Macro Logic/Order?

#showtooltip
/cast [mod:shift,@arena1];[mod:ctrl,@arena2];[mod:alt,@arena3]Cyclone;[harm]Solar Wrath;Lifebloom
/cast [mod:ctrlshift,@focus]Cyclone



Hello all,
I've wondered about this for quite some time now... Can anybody tell me by looking at this macro, if there is anything wrong with it, or what would cause some parts of it to work, and other parts to not work / be ignored? I tried using the [mod:shift,@arena1] to cyclone an Arena1 target, but it wasn't working, while everything else in the macro does. Earlier I had the various [mod]'s in the macro in a different order and it was working, but I can't remember the order, or understand the logic behind it.


It seems to me that certain [mod:shift] or [mod:ctrl] or [mod:alt] or [mod:ctrlshift] etc. etc. needs to go in a certain order in the macro. For example, like if a [mod:alt] is in the macro before a [mod:shift] then the [mod:shift] gets ignored? (This example may not be 100% accurate, but I've experienced something exactly like this before). Before I've had to experiment with which [mod] goes first until eventually it worked.


Is there some sort of logic these macros use, where certain things MUST go in a certain order? I had to put the [mod:ctrlshift, @focus] part of my macro at the end on its own new line, separate from the first part, otherwise the macro would ignore the @focus portion of it.


Sorry it's a bit verbose, and hopefully what I said made sense... But any help or enlightenment would be EXTREMELY appreciated, so that I can know once and for all the method behind the madness of WoW's Macro Logic... Thank you in advance!
  Reply With Quote
05-27-18, 12:31 PM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,877
#showtooltip
/cast [mod:shift,@arena1];[mod:ctrl,@arena2];[mod:alt,@arena3]Cyclone;[harm]Solar Wrath;Lifebloom
/cast [mod:ctrlshift,@focus]Cyclone


I'm not aware of any order of importance in this example but I could be wrong.

What I see is as follows, while pressing the button:

if you press shift while targeting arena1 ( I assume this is the unit id) then it will cast Cyclone
if you press ctrl while targeting arena2 it will cast Cyclone
if you press alt while targetting arena3 it will cast Cyclone
Otherwise if you are targetting an enemy it will cast Solar Wrath to harm them
Or if you are targetting a friend it will cast Lifebloom

However, because you have put ';' after each mod test it may terminate that test and move straight to the [harm] test.

I believe it then waits for the global cooldown before validating the next line which
While pressing ctrl and shift and you have an active focus it will cast Cyclone on them.

However, it may skip over the second line due to time constraints on the first line's functionality

The following may work ( untested ) so that all tests are made before deciding if Cyclone needs to be cast, and if not then react on the harm test options.
/cast [mod:shift,@arena1],[mod:ctrl,@arena2],[mod:alt,@arena3],[mod:ctrlshift,@focus] Cyclone; [harm]Solar Wrath;Lifebloom
__________________
  Reply With Quote
05-27-18, 12:46 PM   #3
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
The commas between brackets are wrong. You can also put it all on one line.

Code:
#showtooltip
/cast [mod:ctrl,mod:shift,@focus][mod:shift,@arena1][mod:ctrl,@arena2][mod:alt,@arena3]Cyclone;[harm]Solar Wrath;Lifebloom
Semicolons are a shortcut to avoid an extra line. Commas are for two or more conditions within brackets. Also, "ctrlshift" is not a valid modifier argument, you have to have the modifier keys separate to use both. The second Cyclone should be first as well because the arena1 will trigger since you're holding shift, ignoring ctrl if you're holding it.

This is the same macro with no semicolons:

Code:
#showtooltip
/cast [mod:ctrl,mod:shift,@focus]Cyclone
/cast [mod:shift,@arena1][mod:ctrl,@arena2][mod:alt,@arena3]Cyclone
/cast [harm]Solar Wrath
/cast Lifebloom

Last edited by Kanegasi : 05-27-18 at 12:50 PM.
  Reply With Quote
05-27-18, 12:50 PM   #4
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,877
thanks, I wasn't 100% sure of the commas, but didn't think the semi colons would cast the spell expected. I'm not on top of the macro conditionals yet, its one of the things holding back writing my own UI

Although come to think of it, maybe I should have looked at some of my macros from my ICC healing times.
__________________
  Reply With Quote
05-27-18, 01:13 PM   #5
Xancepants
A Deviate Faerie Dragon
Join Date: Oct 2014
Posts: 17
if you press shift while targeting arena1 ( I assume this is the unit id) then it will cast Cyclone
if you press ctrl while targeting arena2 it will cast Cyclone
if you press alt while targetting arena3 it will cast Cyclone
Otherwise if you are targetting an enemy it will cast Solar Wrath to harm them
Or if you are targetting a friend it will cast Lifebloom
This is mostly correct, however with the [mod:shift,@arena1], that makes it so you don't have to have anybody targeted. As long as you're holding shift and press your keybind/macro, then it (should) know to cast Cyclone at the Arena1 unit, regardles of who/what you currently have targeted.

I tried out the macro you suggested, and it worked with the exception of the [mod:shift,@focus] portion. It got ignored. HOWEVER, once I put the @focus portion of the macro at the end of the macro, on its own new line, now the macro, as a whole, works! So this is what the finished product looks like:

#showtooltip
/use [mod:shift,@arena1],[mod:ctrl,@arena2],[mod:alt,@arena3]Cyclone;[harm]Solar Wrath;Lifebloom
/use [mod:ctrlshift,@focus]Cyclone
  Reply With Quote
05-28-18, 05:11 AM   #6
aallkkaa
A Warpwood Thunder Caller
 
aallkkaa's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2017
Posts: 98
Ok, I know at least some if not all the people who replied here are far more knowledgeable Lua coders than myself (and in other languages too, I'm sure) , but regarding WoW macros, there were some inaccuracies in their readings of the OP's macro (possibly due to some confusion with Lua conventions?)

Breaking it down:
  • [] Square brackets are used to set a condition within themselves. There are several different types of tests and there is a particular one that is different from all the others, namely the next one on this list:
  • @ "At" (I don't know the actual name of the character in English) This is used inside square brackets (and only inside) to both:
    1. Set the unit the remainder of the tests should be applied against, and
    2. Have the /cast (or /castsequence or /use) be used on said unit (you may do this without any other "tests").
    At any rate, "the other tests" are the ones used inside the same square-brackets closure.
  • ---
  • INSIDE BRACKETS:
    • , Comma means AND;
    • / Slash means OR. There is an exception: [talent:1/1] means talent at row 1 and column 1 (more recent test than most all others; somehow Blizzard thought it a good idea to reuse the same character in a different context to convey a different meaning)
  • BETWEEN BRACKETS
    • [ ] [ ] One pair of brackets (conditions) after the other (spaces optional) means OR;
    • ; Semicolon means ELSE
  • TL;DR: You can use AND only inside a condition (pair of brackets). You can use OR both inside a condition and between conditions. You can use ELSE only between conditions (ELSEIF would be "; [condition]".


That being said, here is what Xancepants' original macro was doing:
*
Code:
/cast [mod:shift,@arena1];[mod:ctrl,@arena2];[mod:alt,@arena3]Cyclone
Does nothing if you hold the shift or ctrl keys down (as there is nothing between the condition [condition] and the semicolon. Would cast cyclone if you held down alt.

*
Code:
[harm]Solar Wrath;Lifebloom
Would cast Solar Wrath if your target were one you could cast harmful abilities on, or Lifebloom otherwise.

*
Code:
/cast [mod:ctrlshift,@focus]Cyclone
Would ERROR on mod:ctrlshift, thus do nothing. Incidentally, it would also almost never do anything if the condition were properly set ( [mod:ctrl,mod:shift,@focus]Cyclone ) because you would be under the GCD triggered by either Solar Wrath or Lifebloom when the macro came to that point (I'm assuming none of the three spells is off the GCD). The only case it would do something were if your target was not one you could harm and you didn't have auto selfcast on (where it would cast Lifebloom on yourself if you had no valid target for it).


This should work as intended:
Code:
#showtooltip
/cast [mod:ctrl,mod:shift,@focus][mod:shift,@arena1][mod:ctrl,@arena2][mod:alt,@arena3]Cyclone;[harm]Solar Wrath;Lifebloom
Do note you need to put [mod:ctrl,mod:shift] before [mod:shift] and [mod:ctrl], because otherwise those conditions will be evaluated to true and the macro execution will jump straight forward to the action to be performed, never reading the conditions that followed the first one that evaluated to true.

Last edited by aallkkaa : 05-28-18 at 05:12 AM. Reason: Fixed messed up tags
  Reply With Quote
05-28-18, 01:14 PM   #7
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,877
Thanks aallkkaa,
Most of it was unknown to me ( despite having parrot fashioned macros rofl ) so I have learnt alot
__________________
  Reply With Quote
05-28-18, 10:31 PM   #8
Xancepants
A Deviate Faerie Dragon
Join Date: Oct 2014
Posts: 17
I KNEW IT! I would tinker around with macro's for years until I eventually got it to work, and through much trial & error, was suspecting that a [mod:ctrlshift] MUST go before any other [conditional] with a singular [mod:] in it. Have definitely learned quite a bit this past week, and @Aallkkaa, you have cleared up the logic behind WoW macro's that I have long, looooong wondered about. Wish I would have asked much sooner. Thank you!

Also huge shout-outs to Xrystal, Kanegasi , and very much to Ammako. You guys are super helpful, and invaluable assets to the WoW community with your coding knowledge. Thank you all!
  Reply With Quote
05-29-18, 04:42 AM   #9
Nimhfree
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 267
The ctrlshift should work without an error. For example, I use this macro for the general professions:

#showtooltip
/cast [mod:shiftctrl]Cooking;[mod:shiftalt]Archaeology;[mod:shift]First Aid;[mod:ctrl]Cooking Fire;[mod:alt]Survey;Fishing

And for an example of the "/" representing OR, here is:

#showtooltip Regrowth
/stopcasting
/cast [nomodifier:ctrl/shift,@mouseover,nodead,help][nomodifier:ctrl/shift,help,nodead][modifier:shift,help,nodead,@focus][modifier:ctrl,@player] Regrowth

which basically says cast Regrowth on one of four units: mouseover, target, focus or self. if no control and no shift are pressed do mouseover or target (if no mouseover), or if shift is pressed do focus, or if ctrl is pressed do self.
  Reply With Quote
05-29-18, 01:57 PM   #10
aallkkaa
A Warpwood Thunder Caller
 
aallkkaa's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2017
Posts: 98
Originally Posted by Nimhfree View Post
The ctrlshift should work without an error.
You're right! I learned something new now. Thank you!

And I'm glad I helped others too.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » Macro Help » Question about Macro Logic/Order?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off