Edit 1/17/11: Here you all go, modified the previous macro to make better use of LUA logic. This one should be somewhat shorter than the one posted a week or so ago, allow for more random mounts to be added before reaching the 255 character cap. Actually, I should have just searched WoWpedia before bothering to do all of this. I reinvented the wheel!
Anyway, I had trouble re-finding a smart mount macro that actually works in Vashj’ir. So as of 4.0.3a, this one will summon the appropriate mount type in all of the Vashj zones as well as everywhere else. The following macro will automatically summon a random mount of your choice depending n the zone that you are in. The number of mounts that you are able to randomly select is limited by the 255 character limit.
/run if not IsMounted() then g,f,s={g,g},{f,f},{s,s} t=(strfind(GetMapInfo(),”Vashj”) and IsSwimming()) and s or IsFlyableArea() and f or g CallCompanion(“MOUNT”,t[random(#t)]) end
/dismount
The bolded variables within the curly brackets need to be replaced with the numbers corresponding to your mounts; You will need to open up your mounts tab to find that. ‘g‘ is for ground, ‘f‘ is for flying and ‘s‘ is for swimming. Keep in mind that they are counted from left to right, top to bottom. Whenever you obtain a new mount, you will most likely need to update the maro since everything is going to be shifted over by one.
- If you are swimming in Vashj’ir your swimming mount will be summoned. You must be swimming and not standing on the ocean floor.
- If you are in Vashj’ir and NOT swimming (on the sandy beach for example), your flying mount will be summoned.
- If you are in a flyable zone, your flying mount will be selected, if not you will summon your ground mount.
- Pressing the macro while mounted will dismount you.
For example
/run if not IsMounted() then g,f,s={14},{31,8},{1} t=(strfind(GetMapInfo(),”Vashj”) and IsSwimming()) and s or IsFlyableArea() and f or g CallCompanion(“MOUNT”,t[random(#t)]) end
/dismount
The ground mount that I want to use, the Fossilized Raptor is located at position 14 (second mount on the second page of my mount tab). Since there are two flying mounts that I like, I want the macro to randomly choose one to summon when I am in a flyable zone. These mounts are the ugly purple drake and the bronze drake at positions 31 and 8 respectively. Additional mounts can be added with a comma separation.
Full explanation
For anyone who is interested in how things work, here is a somewhat verbose explanation as to how the macro and its individual parts work:
/run if not IsMounted() then g,f,s={g,g},{f,f},{s,s}
Only run this line if you are not mounted. If you are mounted, skip to the last nine and dismount. We are declaring three arrays: g, f and s for ground, flying and swimming respectively.
t=(strfind(GetMapInfo(),”Vashj”) and IsSwimming()) and s or IsFlyableArea() and f or g
This is the main logic chunk for the macro. If you look at the last line of the macro (well second to last), ‘t’ is being used to randomly summon a mount. The entire purpose of this line of code is to assign the correct array (‘g’, ‘f’ or ‘s’) to ‘t’ depending on where you are in the world.
LUA handles binary operators (AND, OR) a little differently. For AND operators: Instead of just returning a binary value (true/falso, 1/0) to an expression, WoW LUA will return the first argument if the first value is false and the second argument if the first argument is true. So for example let’s evaluate this statement: false and pie. Since the first argument is false (literally and figuratively), false is returned. Now evaluate this statement: true and cake. Since the first argument is true, cake is returned.
OR operators are handled in the opposite manner. If the first argument is true, the first argument is returned. If the first argument is false, the second argument is returned. So for example: false or pie. The first argument is false so pie is returned. Second example: true or cakes. Since the first argument is true, true is returned. So breaking this line down further:
(strfind(GetMapInfo(),”Vashj”) and IsSwimming()) and s
First argument: (strfind(GetMapInfo(),”Vashj”) and IsSwimming())
Second argument: s
Operator: AND
If you are swimming in a zone starting with the string “Vashj”, the first argument is true. Given what I have stated above regarding the AND operator, the value ‘s’ would be returned and your swimming mount would be summoned. If the first argument is false (you are not in Vashj’ir or not swimming), false would be returned and we would move on to the next statement below
(strfind(GetMapInfo(),”Vashj”) and IsSwimming()) and s or IsFlyableArea() and f
First argument: (strfind(GetMapInfo(),”Vashj”) and IsSwimming()) and s
Second argument: IsFlyableArea() and f
Operator: OR
If ‘s’ was returned we are done; your swimming mount has been summoned. If the first argument however is false, we move on to the second argument. If you are in a flyable area, ‘f’ is returned and your flying mount is summoned. If not your ground mount is summoned.
Hope that was clear enough.