Mercurial > wow > mylilpony
view 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 |
line wrap: on
line source
-- libMyLilPony -- Copyright (c) 2011 Syzler -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. -- Misc helper functions used in the library --- 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. function MyLilPony.GetUnitBuffs(unit) local buffs = {}; for i = 1, 40 do local _, _, _, _, _, _, _, _, _, _, id = UnitAura(unit, i, "HELPFUL"); if id ~= nil then buffs[id] = id; end end return buffs; end --- Performs case-insensitive string pattern matching. -- @param subject The string on which the pattern matching is performed. -- @param pattern The pattern to be matched. -- @returns The match result captures, the entire string if there are no captures, or nil if the subject is not a match. function MyLilPony.StringMatchIgnoreCase(subject, pattern) if subject == nil and pattern == nil then return true end if subject == nil or pattern == nil then return false end local lSub = string.lower(subject); local lPat = string.lower(pattern); return string.match(lSub, lPat); end --- Calls a companion if a specified condition checks out. -- @param companionType The type of companion to be called (e.g. "MOUNT"). -- @param companionNumber The slot number of the companion to be called. -- @param condition An optional Boolean condition. function MyLilPony.CallCompanion(companionType, companionNumber, condition) if condition == nil or condition then CallCompanion(companionType, companionNumber); end end --- Gets a value indicating whether or not the current character is able to fly at the current location. -- 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). -- @returns A Boolean value indicating whether or not the current character is able to fly at the current location. function MyLilPony.CanFlyHere() if IsFlyableArea() then SetMapToCurrentZone(); local continent = GetCurrentMapContinent(); if continent == 4 then -- Northrend: requires Cold Weather Flying return IsSpellKnown(54197); elseif (continent == 1 or continent == 2) then -- Old World: requires Flight Master's License return IsSpellKnown(90267); end return true; end return false; end function MyLilPony.Print(msg) DEFAULT_CHAT_FRAME:AddMessage("|cff8ed6f0"..msg); end function MyLilPony.Log(msg) if MYLILPONY_DEBUG_LOGGING then DEFAULT_CHAT_FRAME:AddMessage("|cff8ed6f0"..format("MyLilPony: %s", msg)); end end