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