Lua Code:
SLASH_MOUNTAHOLIC1 = "/mountaholic"
function SlashCmdList.MOUNTAHOLIC(msg, editbox)
if msg == "a" then -- aquatic
Mountaholic_aquatic()
elseif msg == "g" then -- ground
Mountaholic_ground()
elseif msg == "gf" then -- ground favorites
Mountaholic_favground()
elseif msg == "f" then -- flying
Mountaholic_flying()
elseif msg == "ff" then -- flying favorites
Mountaholic_favflying()
elseif msg == "v" then -- vendor
Mountaholic_vendor()
else
InterfaceOptionsFrame_OpenToCategory(Mountaholic_Options)
end
end
local mounts = {aquatic = {}, flying = {}, flyingf = {}, ground = {}, groundf = {}, vendor = {}}
local amount = GetNumCompanions("mount")
for i = 1, amount do
local creatureID, creatureName, creatureSpellID, icon, issummoned, mountType = GetCompanionInfo("mount",i)
if creatureName == "Traveler's Tundra Mammoth" or creatureName == "Grand Expedition Yak" then
tinsert(mounts.vendor, {i, creatureID, creatureName, creatureSpellID, icon, issummoned, mountType})
end
if bit.band(mountType, 0x01) == 0 and bit.band(mountType, 0x02) == 0 and bit.band(mountType, 0x08) ~= 0 then
tinsert(mounts.aquatic, {i, creatureID, creatureName, creatureSpellID, icon, issummoned, mountType})
elseif bit.band(mountType, 0x02) ~= 0 then
tinsert(mounts.flying, {i, creatureID, creatureName, creatureSpellID, icon, issummoned, mountType})
elseif bit.band(mountType, 0x01) ~= 0 then
tinsert(mounts.ground, {i, creatureID, creatureName, creatureSpellID, icon, issummoned, mountType})
end
end
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)
function Mountaholic_aquatic() -- aquatic
if not IsSwimming() then
print("You can't use an aquatic mount here! Try this instead.")
Mountaholic_flying()
else
local rand = mounts.aquatic[math.random(1, sizea)]
CallCompanion("MOUNT",rand[1])
end
end
function Mountaholic_flying() -- flying
if not IsFlyableArea() then
Mountaholic_ground()
else
local rand = mounts.flying[math.random(1, sizef)]
CallCompanion("MOUNT",rand[1])
end
end
function Mountaholic_ground() -- ground
local rand = mounts.ground[math.random(1, sizeg)]
CallCompanion("MOUNT",rand[1])
end
function Mountaholic_favflying() -- favorite flying
if not IsFlyableArea() then
Mountaholic_ground()
elseif sizeff == 0 then
print("You have no favorite flying mounts! Here, have a random one instead.")
Mountaholic_flying()
else
local rand = mounts.flyingf[math.random(1, sizeff)]
CallCompanion("MOUNT",rand[1])
end
end
function Mountaholic_favground() -- favorite ground
if sizegf == 0 then
print("You have no favorite ground mounts! Here, have a random one instead.")
Mountaholic_ground()
else
local rand = mounts.groundf[math.random(1, sizegf)]
CallCompanion("MOUNT",rand[1])
end
end
function Mountaholic_vendor() -- vendor
local rand = mounts.vendor[math.random(1, sizev)]
CallCompanion("MOUNT",rand[1])
end