Mercurial > wow > mylilpony
view libMyLilPony/libMyLilPony_miscFunctions.lua @ 48:83e9649a6606 1.1.7
Fixed Abyssal Seahorse mounting in certain subzones of Vashj'ir
author | syzler |
---|---|
date | Thu, 20 Sep 2012 01:28:44 -0400 |
parents | 21764271e02f |
children | 22011265a16f |
line wrap: on
line source
-- Copyright (c) 2011, Syzler -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions -- are met: -- -- * Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in -- the documentation and/or other materials provided with the -- distribution. -- * Neither the name of the MyLilPony Project nor the names of its -- contributors may be used to endorse or promote products derived -- from this software without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -- COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------ -- Project: libMyLilPony -- Project Version: @project-version@ -- Last Author: @file-author@ -- Last Updated: @file-date-iso@ -- -- 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