Mercurial > wow > mylilpony
comparison libMyLilPony/libMyLilPony_miscFunctions.lua @ 7:d96c15f7477b
Updated documentation for API.
| author | syzler |
|---|---|
| date | Tue, 05 Apr 2011 02:05:57 +0000 |
| parents | 7dfbf42c2d60 |
| children | b1e344c17ab5 |
comparison
equal
deleted
inserted
replaced
| 6:21d6611a1307 | 7:d96c15f7477b |
|---|---|
| 14 -- You should have received a copy of the GNU General Public License | 14 -- You should have received a copy of the GNU General Public License |
| 15 -- along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 -- along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | 16 |
| 17 -- Misc helper functions used in the library | 17 -- Misc helper functions used in the library |
| 18 | 18 |
| 19 --- Gets a hashtable of buffs on the specified unit. | |
| 20 -- @param unit The unit frame name (e.g. "target", "player", "focus") of the unit whose buffs are to be retrieved. | |
| 21 -- @returns a hashtable of buff spell IDs keyed on the ID. | |
| 19 function MyLilPony.GetUnitBuffs(unit) | 22 function MyLilPony.GetUnitBuffs(unit) |
| 20 -- build a hashtable of buffs on the unit | |
| 21 local buffs = {}; | 23 local buffs = {}; |
| 22 for i = 1, 40 do | 24 for i = 1, 40 do |
| 23 local _, _, _, _, _, _, _, _, _, _, id = UnitAura(unit, i, "HELPFUL"); | 25 local _, _, _, _, _, _, _, _, _, _, id = UnitAura(unit, i, "HELPFUL"); |
| 24 if id ~= nil then | 26 if id ~= nil then |
| 25 buffs[id] = id; | 27 buffs[id] = id; |
| 26 end | 28 end |
| 27 end | 29 end |
| 28 return buffs; | 30 return buffs; |
| 29 end | 31 end |
| 30 | 32 |
| 33 --- Performs case-insensitive string pattern matching. | |
| 34 -- @param subject The string on which the pattern matching is performed. | |
| 35 -- @param pattern The pattern to be matched. | |
| 36 -- @returns The match result captures, the entire string if there are no captures, or nil if the subject is not a match. | |
| 31 function MyLilPony.StringMatchIgnoreCase(subject, pattern) | 37 function MyLilPony.StringMatchIgnoreCase(subject, pattern) |
| 32 if subject == nil and pattern == nil then return true end | 38 if subject == nil and pattern == nil then return true end |
| 33 if subject == nil or pattern == nil then return false end | 39 if subject == nil or pattern == nil then return false end |
| 34 local lSub = string.lower(subject); | 40 local lSub = string.lower(subject); |
| 35 local lPat = string.lower(pattern); | 41 local lPat = string.lower(pattern); |
| 36 return string.match(lSub, lPat); | 42 return string.match(lSub, lPat); |
| 37 end | 43 end |
| 38 | 44 |
| 45 --- Calls a companion if a specified condition checks out. | |
| 46 -- @param companionType The type of companion to be called (e.g. "MOUNT"). | |
| 47 -- @param companionNumber The slot number of the companion to be called. | |
| 48 -- @param condition An optional Boolean condition. | |
| 39 function MyLilPony.CallCompanion(companionType, companionNumber, condition) | 49 function MyLilPony.CallCompanion(companionType, companionNumber, condition) |
| 40 if condition == nil or condition then | 50 if condition == nil or condition then |
| 41 CallCompanion(companionType, companionNumber); | 51 CallCompanion(companionType, companionNumber); |
| 42 end | 52 end |
| 43 end | 53 end |
| 44 | 54 |
| 55 --- Gets a value indicating whether or not the current character is able to fly at the current location. | |
| 56 -- This function checks whether or not the current location is a flyable area, and then additionally checks for knowledge of the proper flying skill (e.g. Cold Weather Flying for Northrend). | |
| 57 -- @returns A Boolean value indicating whether or not the current character is able to fly at the current location. | |
| 45 function MyLilPony.CanFlyHere() | 58 function MyLilPony.CanFlyHere() |
| 46 if IsFlyableArea() then | 59 if IsFlyableArea() then |
| 47 SetMapToCurrentZone(); | 60 SetMapToCurrentZone(); |
| 48 local continent = GetCurrentMapContinent(); | 61 local continent = GetCurrentMapContinent(); |
| 49 if continent == 4 then | 62 if continent == 4 then |
