Saturday, December 11, 2010

Mount distraction

So in Vashj'ir it's possible to get underwater mounts, which is quite cool. But these mounts never work outside of Vashj'ir. And of course a flying mount isn't so useful underwater.

I decided I wanted one button for either a flying mount or the swimming mount. This was quite a challenge! First I just tried it. That fail'd. Then I grabbed this mount macro from Wowwiki:

/run if not IsMounted() then local g,f,s={g,g,g,},{f,f,f},{s,s,s} local t=GetRealZoneText()=="Vashj'ir" and s or (IsFlyableArea() and not IsShiftKeyDown()) and f or g CallCompanion("MOUNT",t[random(#t)]) end
/dismount

This macro seriously does not work. The primary problem is that GetRealZoneText() doesn't provide "Vashj'ir". It provides, like, 'Shimmering Expanse'. And there are three such zones. Thus began my adventure in experiments with Lua. I tried defining a list of zones and putting a for loop, but it just didn't work.

Finally I got something working, with help from my guildie Point, who did most of the heavy liftingexplained to me that {g,g,g,} is really a hash, not a list. the for loop needs two variables iterating over an iterable expression.

/run local t={16,18}; local zones={"Shimmering Expanse","Abyssal Depths","Kelp'Thar Forest"}; for z,n in ipairs(zones) do if (n==GetRealZoneText() and IsSwimming()) then t={1} end end CallCompanion("MOUNT",t[random(#t)])
/dismount


EDIT: Actually that doesn't work either, it doesn't dismount right. Here's the final one.

/run if not IsMounted() then local t={16,18}; local zns={"Shimmering Expanse","Abyssal Depths","Kelp'Thar Forest"}; for z,n in ipairs(zns) do if (n==GetRealZoneText() and IsSwimming()) then t={1} end end CallCompanion("MOUNT",t[random(#t)]) end
/dismount

No comments: