Advertisement
Lasivian

LUA 5.1

Oct 19th, 2024
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.99 KB | None | 0 0
  1. -- Initialize random seed for Lua 5.1
  2. math.randomseed(os.time())
  3.  
  4. mountListGround = {
  5.     "Black War Bear",
  6.     "Purple Hawkstrider",
  7.     "Black War Wolf",
  8.     "Summon Charger",
  9.     "Traveler's Tundra Mammoth"
  10. }
  11.  
  12. mountListFlying = {
  13.     "Green Proto-Drake",
  14.     "Blue Wind Rider",
  15.     "Albino Drake"
  16. }
  17.  
  18. -- First run after reloading - getting indices
  19. if not builtIndices then
  20.  
  21.     mountListGroundIndices = {}
  22.     mountListFlyingIndices = {}
  23.     mountListWintergraspIndices = {}
  24.  
  25.     for i = 1, GetNumCompanions("MOUNT") do
  26.         local id, name = GetCompanionInfo("MOUNT", i)
  27.         if tContains(mountListGround, name) then
  28.             tinsert(mountListGroundIndices, i)
  29.             if name ~= "Purple Hawkstrider" then
  30.                 tinsert(mountListWintergraspIndices, i)
  31.             end
  32.         end
  33.         if tContains(mountListFlying, name) then
  34.             tinsert(mountListFlyingIndices, i)
  35.         end
  36.         if name == "Traveler's Tundra Mammoth" then
  37.             tundraIndex = i
  38.         end
  39.     end
  40.     builtIndices = true
  41. end
  42.  
  43. -- Random CallCompanion alias
  44. function callMount(indexTable)
  45.     CallCompanion("MOUNT", indexTable[math.random(#indexTable)])
  46. end
  47.  
  48. -- Dismounter
  49. if not IsFlying() and IsMounted() then
  50.     Dismount()
  51. end
  52.  
  53. -- Main function
  54. if not InCombatLockdown() then
  55.     cancelShapeshifts()
  56.     if IsAltKeyDown() then
  57.         CallCompanion("MOUNT", tundraIndex)
  58.     else
  59.         if not IsFlyableArea() then
  60.             callMount(mountListGroundIndices)
  61.         else
  62.             if not IsFlying() then
  63.                 if IsShiftKeyDown() then
  64.                     callMount(mountListGroundIndices)
  65.                 else
  66.                     if GetZoneText() == "Wintergrasp" and not GetWintergraspWaitTime() then
  67.                         callMount(mountListWintergraspIndices)
  68.                     else
  69.                         callMount(mountListFlyingIndices)
  70.                     end
  71.                 end
  72.             end
  73.         end
  74.     end
  75. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement