View Single Post
08-01-13, 07:14 AM   #9
Niketa
A Wyrmkin Dreamwalker
 
Niketa's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2013
Posts: 54
Lua Code:
  1. SLASH_MOUNTAHOLIC1 = "/mountaholic"
  2.  
  3. function SlashCmdList.MOUNTAHOLIC(msg, editbox)
  4.     if msg == "a" then -- aquatic
  5.         Mountaholic_aquatic()
  6.     elseif msg == "g" then -- ground
  7.         Mountaholic_ground()
  8.     elseif msg == "gf" then -- ground favorites
  9.         Mountaholic_favground()
  10.     elseif msg == "f" then -- flying
  11.         Mountaholic_flying()
  12.     elseif msg == "ff" then -- flying favorites
  13.         Mountaholic_favflying()
  14.     elseif msg == "v" then -- vendor
  15.         Mountaholic_vendor()
  16.     else
  17.         InterfaceOptionsFrame_OpenToCategory(Mountaholic_Options)
  18.     end
  19. end
  20.  
  21. local mounts = {aquatic = {}, flying = {}, flyingf = {}, ground = {}, groundf = {}, vendor = {}}
  22. local amount = GetNumCompanions("mount")
  23.  
  24. for i = 1, amount do
  25.     local creatureID, creatureName, creatureSpellID, icon, issummoned, mountType = GetCompanionInfo("mount",i)
  26.                        
  27.     if creatureName == "Traveler's Tundra Mammoth" or creatureName == "Grand Expedition Yak" then
  28.         tinsert(mounts.vendor, {i, creatureID, creatureName, creatureSpellID, icon, issummoned, mountType})
  29.     end
  30.                        
  31.     if bit.band(mountType, 0x01) == 0 and bit.band(mountType, 0x02) == 0 and bit.band(mountType, 0x08) ~= 0 then
  32.         tinsert(mounts.aquatic, {i, creatureID, creatureName, creatureSpellID, icon, issummoned, mountType})
  33.     elseif bit.band(mountType, 0x02) ~= 0 then
  34.         tinsert(mounts.flying, {i, creatureID, creatureName, creatureSpellID, icon, issummoned, mountType})
  35.     elseif bit.band(mountType, 0x01) ~= 0 then
  36.         tinsert(mounts.ground, {i, creatureID, creatureName, creatureSpellID, icon, issummoned, mountType})
  37.     end
  38. end
  39.            
  40. local sizea, sizef, sizeff, sizeg, sizegf, sizev = table.getn(mounts.aquatic), table.getn(mounts.flying), table.getn(mounts.flyingf), table.getn(mounts.ground), table.getn(mounts.groundf), table.getn(mounts.vendor)
  41.  
  42.  
  43. function Mountaholic_aquatic() -- aquatic
  44.     if not IsSwimming() then
  45.         print("You can't use an aquatic mount here! Try this instead.")
  46.         Mountaholic_flying()
  47.     else
  48.         local rand = mounts.aquatic[math.random(1, sizea)]
  49.         CallCompanion("MOUNT",rand[1])
  50.     end
  51. end
  52.  
  53. function Mountaholic_flying() -- flying
  54.     if not IsFlyableArea() then
  55.         Mountaholic_ground()
  56.     else
  57.         local rand = mounts.flying[math.random(1, sizef)]
  58.         CallCompanion("MOUNT",rand[1])
  59.     end
  60. end
  61.  
  62. function Mountaholic_ground() -- ground
  63.     local rand = mounts.ground[math.random(1, sizeg)]
  64.     CallCompanion("MOUNT",rand[1])
  65. end
  66.  
  67. function Mountaholic_favflying() -- favorite flying
  68.     if not IsFlyableArea() then
  69.         Mountaholic_ground()
  70.     elseif sizeff == 0 then
  71.         print("You have no favorite flying mounts! Here, have a random one instead.")
  72.         Mountaholic_flying()
  73.     else   
  74.         local rand = mounts.flyingf[math.random(1, sizeff)]
  75.         CallCompanion("MOUNT",rand[1])
  76.     end
  77. end
  78.  
  79. function Mountaholic_favground() -- favorite ground
  80.     if sizegf == 0 then
  81.         print("You have no favorite ground mounts! Here, have a random one instead.")
  82.         Mountaholic_ground()
  83.     else   
  84.         local rand = mounts.groundf[math.random(1, sizegf)]
  85.         CallCompanion("MOUNT",rand[1])
  86.     end
  87. end
  88.  
  89. function Mountaholic_vendor() -- vendor
  90.     local rand = mounts.vendor[math.random(1, sizev)]
  91.     CallCompanion("MOUNT",rand[1])
  92. end
  Reply With Quote