Mercurial > wow > mylilpony
changeset 52:64e8f8e5fa41
Simplified some functions since mount type is can be determined from slot ID
author | syzler |
---|---|
date | Sat, 07 Mar 2015 14:15:17 -0500 |
parents | 9d3c8c1e84f3 |
children | e15807a7d9b5 |
files | libMyLilPony/libMyLilPony.lua libMyLilPony/libMyLilPony_miscFunctions.lua libMyLilPony/libMyLilPony_mountData.lua libMyLilPony/libMyLilPony_mountFunctions.lua libMyLilPony/readme.txt |
diffstat | 5 files changed, 74 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/libMyLilPony/libMyLilPony.lua Sat Mar 07 02:55:27 2015 -0500 +++ b/libMyLilPony/libMyLilPony.lua Sat Mar 07 14:15:17 2015 -0500 @@ -1,4 +1,4 @@ --- Copyright (c) 2011, Syzler +-- Copyright (c) 2015, Syzler -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without
--- a/libMyLilPony/libMyLilPony_miscFunctions.lua Sat Mar 07 02:55:27 2015 -0500 +++ b/libMyLilPony/libMyLilPony_miscFunctions.lua Sat Mar 07 14:15:17 2015 -0500 @@ -1,4 +1,4 @@ --- Copyright (c) 2011, Syzler +-- Copyright (c) 2015, Syzler -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without @@ -39,7 +39,7 @@ --- Gets a hashtable of buffs on the specified unit. -- @param unit The unit frame name (e.g. "target", "player", "focus") of the unit whose buffs are to be retrieved. --- @returns a hashtable of buff spell IDs keyed on the ID. +-- @returns A hashtable of buff spell IDs keyed on the ID. function MyLilPony.GetUnitBuffs(unit) local buffs = {}; for i = 1, 40 do @@ -74,13 +74,23 @@ end --- Calls a mount if a specified condition checks out. +-- @param slotID The slot ID of the mount to be called. +-- @param condition An optional Boolean condition. +-- @returns True if a mount was summoned, or False otherwise. +function MyLilPony.CallMount(slotID, condition) + if condition == nil or condition then + C_MountJournal.Summon(slotID); + return true; + end + return false; +end + +--- OBSOLETE. Calls a mount if a specified condition checks out. -- @param unused The type of companion to be called (e.g. "MOUNT"). -- @param slotID The slot ID of the mount to be called. -- @param condition An optional Boolean condition. function MyLilPony.CallCompanion(unused, slotID, condition) - if condition == nil or condition then - C_MountJournal.Summon(slotID); - end + MyLilPony.CallMount(slotID, condition); end --- Iterates over all known and non-hidden (i.e. not dead or opposite faction) mount slot IDs.
--- a/libMyLilPony/libMyLilPony_mountData.lua Sat Mar 07 02:55:27 2015 -0500 +++ b/libMyLilPony/libMyLilPony_mountData.lua Sat Mar 07 14:15:17 2015 -0500 @@ -1,4 +1,4 @@ --- Copyright (c) 2012, Syzler +-- Copyright (c) 2015, Syzler -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without @@ -119,7 +119,7 @@ [75207] = "V"; -- abyssal seahorse }; ---- Checks whether or not the specified spell ID is a ground mount. +--- OBSOLETE. Checks whether or not the specified spell ID is a ground mount. -- @param spellId The spell ID of the mount to be checked. -- @return A Boolean value indicating whether or not the specified spell is a ground mount. function MyLilPony.IsGroundMount(spellId) @@ -127,7 +127,7 @@ return entry ~= nil and string.match(entry, "G"); end ---- Checks whether or not the specified spell ID is a flying mount. +--- OBSOLETE. Checks whether or not the specified spell ID is a flying mount. -- @param spellId The spell ID of the mount to be checked. -- @return A Boolean value indicating whether or not the specified spell is a flying mount. function MyLilPony.IsFlyingMount(spellId) @@ -135,7 +135,7 @@ return entry ~= nil and string.match(entry, "A"); end ---- Checks whether or not the specified spell ID is an aquatic mount. +--- OBSOLETE. Checks whether or not the specified spell ID is an aquatic mount. -- @param spellId The spell ID of the mount to be checked. -- @return A Boolean value indicating whether or not the specified spell is an aquatic mount. function MyLilPony.IsAquaticMount(spellId) @@ -143,7 +143,7 @@ return entry ~= nil and string.match(entry, "S"); end ---- Checks whether or not the specified spell ID is a Temple of Ahn'Qiraj mount. +--- OBSOLETE. Checks whether or not the specified spell ID is a Temple of Ahn'Qiraj mount. -- @param spellId The spell ID of the mount to be checked. -- @return A Boolean value indicating whether or not the specified spell is a Temple of Ahn'Qiraj mount. function MyLilPony.IsAhnQirajMount(spellId) @@ -151,10 +151,50 @@ return entry ~= nil and string.match(entry, "Q"); end ---- Checks whether or not the specified spell ID is a Vashj'ir mount. +--- OBSOLETE. Checks whether or not the specified spell ID is a Vashj'ir mount. -- @param spellId The spell ID of the mount to be checked. -- @return A Boolean value indicating whether or not the specified spell is a Vashj'ir mount. function MyLilPony.IsVashjirMount(spellId) local entry = MyLilPony_Mounts[spellId]; return entry ~= nil and string.match(entry, "V"); end + +--- Checks whether or not the specified slot ID is a ground mount. +-- @param slotID The slot ID of the mount to be checked. +-- @return A Boolean value indicating whether or not the specified mount is a ground mount. +function MyLilPony.IsGroundMountSlot(slotID) + local _, _, _, _, mountType = C_MountJournal.GetMountInfoExtra(slotID); + return mountType == 230 or mountType == 284; +end + +--- Checks whether or not the specified slot ID is a flying mount. +-- @param slotID The slot ID of the mount to be checked. +-- @return A Boolean value indicating whether or not the specified mount is a flying mount. +function MyLilPony.IsFlyingMountSlot(slotID) + local _, _, _, _, mountType = C_MountJournal.GetMountInfoExtra(slotID); + return mountType ==247 or mountType == 248; +end + +--- Checks whether or not the specified slot ID is an aquatic mount. +-- @param slotID The slot ID of the mount to be checked. +-- @return A Boolean value indicating whether or not the specified mount is an aquatic mount. +function MyLilPony.IsAquaticMountSlot(slotID) + local _, _, _, _, mountType = C_MountJournal.GetMountInfoExtra(slotID); + return mountType == 231 or mountType == 254; +end + +--- Checks whether or not the specified slot ID is a Temple of Ahn'Qiraj mount. +-- @param slotID The slot ID of the mount to be checked. +-- @return A Boolean value indicating whether or not the specified mount is a Temple of Ahn'Qiraj mount. +function MyLilPony.IsAhnQirajMountSlot(slotID) + local _, _, _, _, mountType = C_MountJournal.GetMountInfoExtra(slotID); + return mountType == 241; +end + +--- Checks whether or not the specified slot ID is a Vashj'ir mount. +-- @param slotID The slot ID of the mount to be checked. +-- @return A Boolean value indicating whether or not the specified mount is a Vashj'ir mount. +function MyLilPony.IsVashjirMountSlot(slotID) + local _, _, _, _, mountType = C_MountJournal.GetMountInfoExtra(slotID); + return mountType == 232 or mountType == 231 or mountType == 254; +end
--- a/libMyLilPony/libMyLilPony_mountFunctions.lua Sat Mar 07 02:55:27 2015 -0500 +++ b/libMyLilPony/libMyLilPony_mountFunctions.lua Sat Mar 07 14:15:17 2015 -0500 @@ -1,4 +1,4 @@ --- Copyright (c) 2011, Syzler +-- Copyright (c) 2015, Syzler -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without @@ -54,7 +54,7 @@ function MyLilPony.CallFlyingMount() local filter = function (i) local _, id, _, summoned = C_MountJournal.GetMountInfo(i); - return not summoned and MyLilPony.IsFlyingMount(id); + return not summoned and MyLilPony.IsFlyingMountSlot(i); end return MyLilPony.CallMountByFilter(filter); end @@ -65,7 +65,7 @@ function MyLilPony.CallGroundMount() local filter = function (i) local _, id, _, summoned = C_MountJournal.GetMountInfo(i); - return not summoned and MyLilPony.IsGroundMount(id); + return not summoned and MyLilPony.IsGroundMountSlot(i); end return MyLilPony.CallMountByFilter(filter); end @@ -76,7 +76,7 @@ function MyLilPony.CallAquaticMount() local filter = function (i) local _, id, _, summoned = C_MountJournal.GetMountInfo(i); - return not summoned and MyLilPony.IsAquaticMount(id); + return not summoned and MyLilPony.IsAquaticMountSlot(i); end return MyLilPony.CallMountByFilter(filter); end @@ -89,7 +89,7 @@ local countMounts = C_MountJournal.GetNumMounts(); if slotNumber > 0 and slotNumber < countMounts+1 then local _, _, _, summoned = C_MountJournal.GetMountInfo(i); - MyLilPony.CallCompanion("MOUNT", slotNumber, not summoned); + MyLilPony.CallMount(slotNumber, not summoned); return true; end return false; @@ -104,7 +104,7 @@ for i in MyLilPony.EnumerateKnownMountSlotIDs() do local name, _, _, summoned = C_MountJournal.GetMountInfo(i); if name == mountName then - MyLilPony.CallCompanion("MOUNT", i, not summoned); + MyLilPony.CallMount(i, not summoned); result = true; do break end end @@ -135,7 +135,7 @@ local _, spellId, _, summoned = C_MountJournal.GetMountInfo(i); local creatureId = C_MountJournal.GetMountInfoExtra(i); if id == creatureId or id == spellId then - MyLilPony.CallCompanion("MOUNT", i, not summoned); + MyLilPony.CallMount(i, not summoned); result = true; do break end end @@ -152,7 +152,7 @@ for i in MyLilPony.EnumerateKnownMountSlotIDs() do local _, id, _, summoned = C_MountJournal.GetMountInfo(i); if id == spellId then - MyLilPony.CallCompanion("MOUNT", i, not summoned); + MyLilPony.CallMount(i, not summoned); result = true; do break end end @@ -170,7 +170,7 @@ local _, _, _, summoned = C_MountJournal.GetMountInfo(i); local id = C_MountJournal.GetMountInfoExtra(i); if id == creatureId then - MyLilPony.CallCompanion("MOUNT", i, not summoned); + MyLilPony.CallMount(i, not summoned); result = true; do break end end @@ -191,7 +191,7 @@ for i in MyLilPony.EnumerateKnownMountSlotIDs() do local _, id, _, summoned = C_MountJournal.GetMountInfo(i); if unitBuffs[id] ~= nil then - MyLilPony.CallCompanion("MOUNT", i, not summoned); + MyLilPony.CallMount(i, not summoned); result = true; do break end end @@ -221,7 +221,7 @@ if x > 0 then local i = mounts[random(1, x)]; local _, _, _, summoned = C_MountJournal.GetMountInfo(i); - MyLilPony.CallCompanion("MOUNT", i, not summoned); + MyLilPony.CallMount(i, not summoned); return true; end return false;