Mercurial > wow > mylilpony
changeset 6:21d6611a1307
Documented mountFunctions
author | syzler |
---|---|
date | Tue, 05 Apr 2011 01:11:23 +0000 |
parents | a4711e3c1eef |
children | d96c15f7477b |
files | libMyLilPony/libMyLilPony_mountFunctions.lua |
diffstat | 1 files changed, 82 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/libMyLilPony/libMyLilPony_mountFunctions.lua Tue Apr 05 00:49:50 2011 +0000 +++ b/libMyLilPony/libMyLilPony_mountFunctions.lua Tue Apr 05 01:11:23 2011 +0000 @@ -18,7 +18,7 @@ --- Summons a random mount. -- Does nothing if the only available mount is already summoned. --- @return A Boolean value indicating whether or not a new mount was summoned. +-- @return A Boolean value indicating whether or not a mount was successfully summoned. function MyLilPony.CallMount() local filter = function (i) local _, _, _, _, summoned = GetCompanionInfo("MOUNT", i); @@ -27,6 +27,9 @@ return MyLilPony.CallMountByFilter(filter); end +--- Summons a random flying mount. +-- Does nothing if the only available mount is already summoned. +-- @return A Boolean value indicating whether or not a mount was successfully summoned. function MyLilPony.CallFlyingMount() local filter = function (i) local _, _, id, _, summoned = GetCompanionInfo("MOUNT", i); @@ -35,6 +38,9 @@ return MyLilPony.CallMountByFilter(filter); end +--- Summons a random ground mount. +-- Does nothing if the only available mount is already summoned. +-- @return A Boolean value indicating whether or not a mount was successfully summoned. function MyLilPony.CallGroundMount() local filter = function (i) local _, _, id, _, summoned = GetCompanionInfo("MOUNT", i); @@ -43,6 +49,9 @@ return MyLilPony.CallMountByFilter(filter); end +--- Summons a random aquatic mount. +-- Does nothing if the only available mount is already summoned. +-- @return A Boolean value indicating whether or not a mount was successfully summoned. function MyLilPony.CallAquaticMount() local filter = function (i) local _, _, id, _, summoned = GetCompanionInfo("MOUNT", i); @@ -51,6 +60,10 @@ return MyLilPony.CallMountByFilter(filter); end +--- Summons a mount by slot number in mount spellbook. +-- Does nothing if the specified mount is already summoned. +-- @param slotNumber The slot number of the desired mount in the mount spellbook. +-- @return A Boolean value indicating whether or not a mount was successfully summoned. function MyLilPony.CallMountBySlot(slotNumber) local countMounts = GetNumCompanions("MOUNT"); if slotNumber > 0 and slotNumber < countMounts+1 then @@ -61,20 +74,29 @@ return false; end +--- Summons a mount by exact name match. +-- Does nothing if the specified mount is already summoned. +-- @param mountName The exact name (including correct upper/lower case) of the desired mount. +-- @return A Boolean value indicating whether or not a mount was successfully summoned. function MyLilPony.CallMountByName(mountName) local result = false; local countMounts = GetNumCompanions("MOUNT"); for i = 1, countMounts do - local _, name, _, _, summoned = GetCompanionInfo("MOUNT", i); - if name == mountName then + local _, name, _, _, summoned = GetCompanionInfo("MOUNT", i); + if name == mountName then MyLilPony.CallCompanion("MOUNT", i, not summoned); result = true; do break end - end - end + end + end return result; end +--- Summons a mount by name pattern match. +-- If the pattern matches multiple mounts, a random one is chosen. +-- Does nothing if the specified mount is already summoned. +-- @param mountNamePattern A string pattern against which mount names are matched (does not require correct upper/lower case). +-- @return A Boolean value indicating whether or not a mount was successfully summoned. function MyLilPony.CallMountByPattern(mountNamePattern) local filter = function (i) local _, name, _, _, summoned = GetCompanionInfo("MOUNT", i); @@ -83,63 +105,91 @@ return MyLilPony.CallMountByFilter(filter); end +--- Summons a mount by creature or spell ID. +-- Does nothing if the specified mount is already summoned. +-- @param id The creature or spell ID of the desired mount. +-- @return A Boolean value indicating whether or not a mount was successfully summoned. function MyLilPony.CallMountById(id) local result = false; local countMounts = GetNumCompanions("MOUNT"); for i = 1, countMounts do - local creatureId, _, spellId, _, summoned = GetCompanionInfo("MOUNT", i); - if id == creatureId or id == spellId then + local creatureId, _, spellId, _, summoned = GetCompanionInfo("MOUNT", i); + if id == creatureId or id == spellId then MyLilPony.CallCompanion("MOUNT", i, not summoned); result = true; do break end - end - end + end + end return result; end +--- Summons a mount by spell ID. +-- Does nothing if the specified mount is already summoned. +-- @param spellId The spell ID of the desired mount. +-- @return A Boolean value indicating whether or not a mount was successfully summoned. function MyLilPony.CallMountBySpell(spellId) local result = false; local countMounts = GetNumCompanions("MOUNT"); for i = 1, countMounts do - local _, _, id, _, summoned = GetCompanionInfo("MOUNT", i); - if id == spellId then + local _, _, id, _, summoned = GetCompanionInfo("MOUNT", i); + if id == spellId then MyLilPony.CallCompanion("MOUNT", i, not summoned); result = true; do break end - end - end + end + end return result; end +--- Summons a mount by creature ID. +-- Does nothing if the specified mount is already summoned. +-- @param creatureId The creature ID of the desired mount. +-- @return A Boolean value indicating whether or not a mount was successfully summoned. function MyLilPony.CallMountByCreature(creatureId) local result = false; local countMounts = GetNumCompanions("MOUNT"); for i = 1, countMounts do - local id, _, _, _, summoned = GetCompanionInfo("MOUNT", i); - if id == creatureId then + local id, _, _, _, summoned = GetCompanionInfo("MOUNT", i); + if id == creatureId then MyLilPony.CallCompanion("MOUNT", i, not summoned); result = true; do break end - end - end + end + end return result; end +--- Summons a mount by attempting to match the mount of the specified unit. +-- The function checks the buffs of the specified unit against the mount spellbook for matches. +-- As a result, the function will only likely work against player characters. +-- Does nothing if the specified unit's mount is already summoned. +-- @param unit The unit frame name (e.g. "target", "player", "focus") of the unit whose mount is desired. +-- @return A Boolean value indicating whether or not a mount was successfully summoned. +-- @usage MyLilPony.CallMountByMatch("target") function MyLilPony.CallMountByMatch(unit) local result = false; local unitBuffs = MyLilPony.GetUnitBuffs(unit); local countMounts = GetNumCompanions("MOUNT"); for i = 1, countMounts do - local _, _, id, _, summoned = GetCompanionInfo("MOUNT", i); - if unitBuffs[id] ~= nil then + local _, _, id, _, summoned = GetCompanionInfo("MOUNT", i); + if unitBuffs[id] ~= nil then MyLilPony.CallCompanion("MOUNT", i, not summoned); result = true; do break end - end - end + end + end return result; end +--- Summons a random mount after filtering the mount spellbook. +-- Does nothing if the specified mount is already summoned. +-- @param filter A filter callback function which takes a single mount slot number and returns a Boolean value indicating whether or not the the indicated mount should be included. +-- @return A Boolean value indicating whether or not a mount was successfully summoned. +-- @usage local filter = function (i) +-- local _, name, _, _, summoned = GetCompanionInfo("MOUNT", i); +-- return not summoned and string.match(name, pattern); +-- end +-- return MyLilPony.CallMountByFilter(filter); function MyLilPony.CallMountByFilter(filter) local countMounts = GetNumCompanions("MOUNT"); if countMounts > 0 then @@ -163,6 +213,8 @@ return false; end +--- Lists available mounts by name. +-- @return A list of mount names. Since this function returns all known mounts, the index of each entry in the list is also the mount's slot number. function MyLilPony.ListMounts() local results = {}; local countMounts = GetNumCompanions("MOUNT"); @@ -173,6 +225,8 @@ return results; end +--- Lists available ground mounts by name. +-- @return A list of ground mount names. function MyLilPony.ListGroundMounts() local results = {}; local countMounts = GetNumCompanions("MOUNT"); @@ -187,6 +241,8 @@ return results; end +--- Lists available flying mounts by name. +-- @return A list of flying mount names. function MyLilPony.ListFlyingMounts() local results = {}; local countMounts = GetNumCompanions("MOUNT"); @@ -201,6 +257,8 @@ return results; end +--- Lists available aquatic mounts by name. +-- @return A list of aquatic mount names. function MyLilPony.ListAquaticMounts() local results = {}; local countMounts = GetNumCompanions("MOUNT"); @@ -215,6 +273,9 @@ return results; end +--- Lists available mounts names whose name matches a given pattern. +-- @param mountNamePattern A string pattern against which mount names are matched (does not require correct upper/lower case). +-- @return A list of matching mount names. function MyLilPony.ListMountsByPattern(mountNamePattern) local results = {}; local countMounts = GetNumCompanions("MOUNT");