Mercurial > wow > mylilpony
comparison libMyLilPony/libMyLilPony_miscFunctions.lua @ 1:7dfbf42c2d60
Initial commit of MyLilPony
author | syzler |
---|---|
date | Mon, 04 Apr 2011 04:43:05 +0000 |
parents | |
children | d96c15f7477b |
comparison
equal
deleted
inserted
replaced
0:f6a1d182682e | 1:7dfbf42c2d60 |
---|---|
1 -- libMyLilPony | |
2 -- Copyright (c) 2011 Syzler | |
3 -- | |
4 -- This program is free software: you can redistribute it and/or modify | |
5 -- it under the terms of the GNU General Public License as published by | |
6 -- the Free Software Foundation, either version 3 of the License, or | |
7 -- (at your option) any later version. | |
8 -- | |
9 -- This program is distributed in the hope that it will be useful, | |
10 -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 -- GNU General Public License for more details. | |
13 -- | |
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/>. | |
16 | |
17 -- Misc helper functions used in the library | |
18 | |
19 function MyLilPony.GetUnitBuffs(unit) | |
20 -- build a hashtable of buffs on the unit | |
21 local buffs = {}; | |
22 for i = 1, 40 do | |
23 local _, _, _, _, _, _, _, _, _, _, id = UnitAura(unit, i, "HELPFUL"); | |
24 if id ~= nil then | |
25 buffs[id] = id; | |
26 end | |
27 end | |
28 return buffs; | |
29 end | |
30 | |
31 function MyLilPony.StringMatchIgnoreCase(subject, pattern) | |
32 if subject == nil and pattern == nil then return true end | |
33 if subject == nil or pattern == nil then return false end | |
34 local lSub = string.lower(subject); | |
35 local lPat = string.lower(pattern); | |
36 return string.match(lSub, lPat); | |
37 end | |
38 | |
39 function MyLilPony.CallCompanion(companionType, companionNumber, condition) | |
40 if condition == nil or condition then | |
41 CallCompanion(companionType, companionNumber); | |
42 end | |
43 end | |
44 | |
45 function MyLilPony.CanFlyHere() | |
46 if IsFlyableArea() then | |
47 SetMapToCurrentZone(); | |
48 local continent = GetCurrentMapContinent(); | |
49 if continent == 4 then | |
50 -- Northrend: requires Cold Weather Flying | |
51 return IsSpellKnown(54197); | |
52 elseif (continent == 1 or continent == 2) then | |
53 -- Old World: requires Flight Master's License | |
54 return IsSpellKnown(90267); | |
55 end | |
56 return true; | |
57 end | |
58 return false; | |
59 end | |
60 | |
61 function MyLilPony.Print(msg) | |
62 DEFAULT_CHAT_FRAME:AddMessage("|cff8ed6f0"..msg); | |
63 end | |
64 | |
65 function MyLilPony.Log(msg) | |
66 if MYLILPONY_DEBUG_LOGGING then | |
67 DEFAULT_CHAT_FRAME:AddMessage("|cff8ed6f0"..format("MyLilPony: %s", msg)); | |
68 end | |
69 end |