# HG changeset patch
# User syzler
# Date 1301892185 0
# Node ID 7dfbf42c2d607645127fd5053fce393031f733eb
# Parent f6a1d182682e52ddac88d09fccb3666f8ff35145
Initial commit of MyLilPony
diff -r f6a1d182682e -r 7dfbf42c2d60 MyLilPony.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MyLilPony.lua Mon Apr 04 04:43:05 2011 +0000
@@ -0,0 +1,173 @@
+-- MyLilPony
+-- 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 .
+
+function MyLilPony.OnLoad()
+ SlashCmdList["MyLilPony"] = MyLilPony.SlashHandler;
+ SLASH_MyLilPony1 = "/pony";
+ SLASH_MyLilPony2 = "/mlp";
+ SLASH_MyLilPony3 = "/mylilpony";
+
+ MyLilPony.Log(format("Version %s loaded", MYLILPONY_VERSION));
+ MyLilPony.LoadDefaults();
+end
+
+function MyLilPony.LoadDefaults()
+ if MyLilPony.AutoDismount == nil then MyLilPony.AutoDismount = true end
+end
+
+function MyLilPony.AutoMount()
+ if UnitIsDead("player") or UnitIsGhost("player") then
+ MyLilPony.Log("You are dead");
+ return;
+ end
+
+ if InCombatLockdown() then
+ MyLilPony.Log("You are in combat");
+ return;
+ end
+
+ if IsMounted() and not MyLilPony.AutoDismount then
+ MyLilPony.Log("You are already mounted");
+ return;
+ end
+
+ if IsMounted() and IsFlying() then
+ MyLilPony.Log("You are already flying");
+ return;
+ end
+
+ local zone = GetRealZoneText();
+
+ -- player is in Temple of Ahn'Qiraj (AQ40)
+ if zone == "Ahn'Qiraj" then
+ if not IsModifierKeyDown() and MyLilPony.CallMountByRegex("Qiraji Battle Tank") then
+ return
+ end
+ end
+
+ -- player is in Wintergrasp
+ if zone == "Wintergrasp" then
+ -- always call ground mount if Wintergrasp is in progress
+ local _, _, wintergraspInProgress, _, _, _ = GetWorldPVPAreaInfo(1);
+ if wintergraspInProgress and MyLilPony.CallGroundMount() then
+ return;
+ end
+ end
+
+ -- player is swimming in Vash'jir
+ if IsSwimming() and (zone == "Shimmering Expanse" or zone == "Kelp'thar Forest" or zone == "Abyssal Depths") then
+ -- normal behaviour in Vash'jir is to call the Abyssal Seahorse
+ -- modified behaviour is to attempt flight (i.e. you're at the surface)
+ if not IsModifierKeyDown() and MyLilPony.CallMountByName("Abyssal Seahorse") then
+ return;
+ elseif MyLilPony.CanFlyHere() and MyLilPony.CallFlyingMount() then
+ return;
+ elseif MyLilPony.CallAquaticMount() then
+ return;
+ end
+ end
+
+ -- player is in flyable area and knows how to fly here too
+ if MyLilPony.CanFlyHere() and not IsModifierKeyDown() then
+ -- normal behaviour in flyable area is to call flying mount
+ if MyLilPony.CallFlyingMount() then
+ return;
+ end
+ end
+
+ -- player is swimming
+ if IsSwimming() and not IsModifierKeyDown() then
+ -- normal behaviour while swimming is to call aquatic mount
+ if MyLilPony.CallAquaticMount() then
+ return;
+ end
+ end
+
+ MyLilPony.CallGroundMount();
+end
+
+function MyLilPony.SlashHandler(arg)
+ if MyLilPony.StringMatchIgnoreCase(arg, "^auto$") then
+ MyLilPony.AutoMount();
+ elseif MyLilPony.StringMatchIgnoreCase(arg, "^random$")
+ or MyLilPony.StringMatchIgnoreCase(arg, "^rand$")
+ or MyLilPony.StringMatchIgnoreCase(arg, "^rng$")
+ or MyLilPony.StringMatchIgnoreCase(arg, "^r$") then
+ MyLilPony.CallMount();
+ elseif MyLilPony.StringMatchIgnoreCase(arg, "^ground$")
+ or MyLilPony.StringMatchIgnoreCase(arg, "^g$") then
+ MyLilPony.CallGroundMount();
+ elseif MyLilPony.StringMatchIgnoreCase(arg, "^flying$")
+ or MyLilPony.StringMatchIgnoreCase(arg, "^fly$")
+ or MyLilPony.StringMatchIgnoreCase(arg, "^air$")
+ or MyLilPony.StringMatchIgnoreCase(arg, "^a$") then
+ MyLilPony.CallFlyingMount();
+ elseif MyLilPony.StringMatchIgnoreCase(arg, "^aquatic$")
+ or MyLilPony.StringMatchIgnoreCase(arg, "^aqua$")
+ or MyLilPony.StringMatchIgnoreCase(arg, "^swim$")
+ or MyLilPony.StringMatchIgnoreCase(arg, "^s$") then
+ MyLilPony.CallAquaticMount();
+ elseif MyLilPony.StringMatchIgnoreCase(arg, "^target$")
+ or MyLilPony.StringMatchIgnoreCase(arg, "^tgt$")
+ or MyLilPony.StringMatchIgnoreCase(arg, "^t$") then
+ local result = MyLilPony.CallMountByMatch("target");
+ if not result then
+ MyLilPony.Log("No matching mounts were found");
+ end
+ elseif MyLilPony.StringMatchIgnoreCase(arg, "^exact .+$")
+ or MyLilPony.StringMatchIgnoreCase(arg, "^x .+$") then
+ local param = MyLilPony.StringMatchIgnoreCase(arg, "^.+ (.+)$");
+ local result = MyLilPony.CallMountByName(param);
+ if not result then
+ MyLilPony.Log(format("No matching mounts were found with NAME='%s'", param));
+ end
+ elseif MyLilPony.StringMatchIgnoreCase(arg, "^list .+$")
+ or MyLilPony.StringMatchIgnoreCase(arg, "^find .+$")
+ or MyLilPony.StringMatchIgnoreCase(arg, "^l .+$") then
+ local param = MyLilPony.StringMatchIgnoreCase(arg, "^.+ (.+)$");
+ local result = MyLilPony.ListMountsByPattern(param);
+ if not result then
+ MyLilPony.Log(format("No matching mounts were found with NAME like '%s'", param));
+ else
+ for _, name in pairs(result) do
+ MyLilPony.Print(name);
+ end
+ end
+ elseif MyLilPony.StringMatchIgnoreCase(arg, "^%d+$") then
+ local result = MyLilPony.CallMountById(tonumber(arg));
+ if not result then
+ MyLilPony.Log(format("No matching mounts were found with ID=%s", arg));
+ end
+ elseif MyLilPony.StringMatchIgnoreCase(arg, "^.+$") then
+ local result = MyLilPony.CallMountByPattern(arg);
+ if not result then
+ MyLilPony.Log(format("No matching mounts were found with NAME like '%s'", arg));
+ end
+ else
+ MyLilPony.Print(format("MyLilPony %s", MYLILPONY_VERSION));
+ MyLilPony.Print("Slash Command: /mylilpony (/pony, /mlp)");
+ MyLilPony.Print(" /mylilpony auto - Summons a \"suitable\" mount");
+ MyLilPony.Print(" /mylilpony random - Summons random mount");
+ MyLilPony.Print(" /mylilpony ground - Summons random ground mount");
+ MyLilPony.Print(" /mylilpony flying - Summons random flying mount");
+ MyLilPony.Print(" /mylilpony aquatic - Summons random aquatic mount");
+ MyLilPony.Print(" /mylilpony target - Summons same mount as targeted unit");
+ MyLilPony.Print(" /mylilpony list - Lists mounts matching name");
+ MyLilPony.Print(" /mylilpony exact - Summons mount by exact name");
+ MyLilPony.Print(" /mylilpony - Summons mount by spell or creature ID");
+ MyLilPony.Print(" /mylilpony - Summons random mount matching name");
+ end
+end
diff -r f6a1d182682e -r 7dfbf42c2d60 MyLilPony.toc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MyLilPony.toc Mon Apr 04 04:43:05 2011 +0000
@@ -0,0 +1,16 @@
+## Interface: 40000
+## Title: MyLilPony
+## Version: 1.0.0
+## Author: Szylar
+## License: GPLv3
+## Notes: Commands for calling ponies and unicorns.
+
+# libMyLilPony 1.0.0
+libMyLilPony\libMyLilPony.lua
+libMyLilPony\libMyLilPony_mountData.lua
+libMyLilPony\libMyLilPony_mountFunctions.lua
+libMyLilPony\libMyLilPony_miscFunctions.lua
+
+# MyLilPony
+MyLilPony.lua
+MyLilPony.xml
\ No newline at end of file
diff -r f6a1d182682e -r 7dfbf42c2d60 MyLilPony.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MyLilPony.xml Mon Apr 04 04:43:05 2011 +0000
@@ -0,0 +1,27 @@
+
+
+
+
+
+ MyLilPony.OnLoad();
+
+
+
+
diff -r f6a1d182682e -r 7dfbf42c2d60 libMyLilPony/libMyLilPony.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libMyLilPony/libMyLilPony.lua Mon Apr 04 04:43:05 2011 +0000
@@ -0,0 +1,23 @@
+-- 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 .
+
+-- This file contains initial declarations for the library
+-- Make sure it loads first :P
+
+MyLilPony = {}
+
+MYLILPONY_VERSION = "1.0.0";
+MYLILPONY_DEBUG_LOGGING = false;
diff -r f6a1d182682e -r 7dfbf42c2d60 libMyLilPony/libMyLilPony_miscFunctions.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libMyLilPony/libMyLilPony_miscFunctions.lua Mon Apr 04 04:43:05 2011 +0000
@@ -0,0 +1,69 @@
+-- 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 .
+
+-- Misc helper functions used in the library
+
+function MyLilPony.GetUnitBuffs(unit)
+ -- build a hashtable of buffs on the 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
+
+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
+
+function MyLilPony.CallCompanion(companionType, companionNumber, condition)
+ if condition == nil or condition then
+ CallCompanion(companionType, companionNumber);
+ end
+end
+
+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
diff -r f6a1d182682e -r 7dfbf42c2d60 libMyLilPony/libMyLilPony_mountData.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libMyLilPony/libMyLilPony_mountData.lua Mon Apr 04 04:43:05 2011 +0000
@@ -0,0 +1,113 @@
+-- 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 .
+
+-- Mount data table and API functions for checking type of mount
+
+local MyLilPony_Mounts = {
+ -- standard ground mounts
+ [458] = "G"; [470] = "G"; [472] = "G"; [579] = "G"; [580] = "G"; [5784] = "G"; [6648] = "G";
+ [6653] = "G"; [6654] = "G"; [6777] = "G"; [6898] = "G"; [6899] = "G"; [8394] = "G"; [8395] = "G";
+ [10789] = "G"; [10793] = "G"; [10795] = "G"; [10796] = "G"; [10799] = "G"; [10873] = "G";
+ [10969] = "G"; [13819] = "G"; [15779] = "G"; [15780] = "G"; [15781] = "G"; [16055] = "G";
+ [16056] = "G"; [16058] = "G"; [16059] = "G"; [16060] = "G"; [16080] = "G"; [16081] = "G";
+ [16082] = "G"; [16083] = "G"; [16084] = "G"; [17229] = "G"; [17450] = "G"; [17453] = "G";
+ [17454] = "G"; [17455] = "G"; [17456] = "G"; [17458] = "G"; [17459] = "G"; [17460] = "G";
+ [17461] = "G"; [17462] = "G"; [17463] = "G"; [17464] = "G"; [17465] = "G"; [17481] = "G";
+ [18363] = "G"; [18989] = "G"; [18990] = "G"; [18991] = "G"; [18992] = "G"; [22717] = "G";
+ [22718] = "G"; [22719] = "G"; [22720] = "G"; [22721] = "G"; [22722] = "G"; [22723] = "G";
+ [22724] = "G"; [23161] = "G"; [23214] = "G"; [23219] = "G"; [23220] = "G"; [23221] = "G";
+ [23222] = "G"; [23223] = "G"; [23225] = "G"; [23227] = "G"; [23228] = "G"; [23229] = "G";
+ [23238] = "G"; [23239] = "G"; [23240] = "G"; [23241] = "G"; [23242] = "G"; [23243] = "G";
+ [23246] = "G"; [23247] = "G"; [23248] = "G"; [23249] = "G"; [23250] = "G"; [23251] = "G";
+ [23252] = "G"; [23338] = "G"; [23509] = "G"; [23510] = "G"; [24242] = "G"; [24252] = "G";
+ [30174] = "G"; [33630] = "G"; [33660] = "G"; [34406] = "G"; [34407] = "G"; [34767] = "G";
+ [34769] = "G"; [34790] = "G"; [34795] = "G"; [34896] = "G"; [34897] = "G"; [34898] = "G";
+ [34899] = "G"; [35018] = "G"; [35020] = "G"; [35022] = "G"; [35025] = "G"; [35027] = "G";
+ [35028] = "G"; [35710] = "G"; [35711] = "G"; [35712] = "G"; [35713] = "G"; [35714] = "G";
+ [36702] = "G"; [39315] = "G"; [39316] = "G"; [39317] = "G"; [39318] = "G"; [39319] = "G";
+ [41252] = "G"; [42776] = "G"; [42777] = "G"; [43688] = "G"; [43899] = "G"; [43900] = "G";
+ [46628] = "G"; [47037] = "G"; [48027] = "G"; [48778] = "G"; [48954] = "G"; [49322] = "G";
+ [49378] = "G"; [49379] = "G"; [50281] = "G"; [50869] = "G"; [51412] = "G"; [54753] = "G";
+ [55531] = "G"; [59572] = "G"; [59573] = "G"; [59785] = "G"; [59788] = "G"; [59791] = "G";
+ [59793] = "G"; [59797] = "G"; [59799] = "G"; [59802] = "G"; [59804] = "G"; [59810] = "G";
+ [59811] = "G"; [60114] = "G"; [60116] = "G"; [60118] = "G"; [60119] = "G"; [60136] = "G";
+ [60140] = "G"; [60424] = "G"; [61425] = "G"; [61447] = "G"; [61465] = "G"; [61466] = "G";
+ [61467] = "G"; [61469] = "G"; [61470] = "G"; [63232] = "G"; [63234] = "G"; [63635] = "G";
+ [63636] = "G"; [63637] = "G"; [63638] = "G"; [63639] = "G"; [63640] = "G"; [63641] = "G";
+ [63642] = "G"; [63643] = "G"; [64657] = "G"; [64658] = "G"; [64659] = "G"; [64977] = "G";
+ [65637] = "G"; [65638] = "G"; [65639] = "G"; [65640] = "G"; [65641] = "G"; [65642] = "G";
+ [65643] = "G"; [65644] = "G"; [65645] = "G"; [65646] = "G"; [66091] = "G"; [66846] = "G";
+ [66847] = "G"; [66906] = "G"; [67466] = "G"; [68056] = "G"; [68188] = "G"; [73313] = "G";
+ [74918] = "G"; [87090] = "G"; [87091] = "G"; [88748] = "G"; [88749] = "G"; [88750] = "G";
+ [92231] = "G";
+
+ -- standard flying mounts
+ [3363] = "A"; [28828] = "A"; [32235] = "A"; [32239] = "A"; [32240] = "A"; [32242] = "A";
+ [32243] = "A"; [32244] = "A"; [32245] = "A"; [32246] = "A"; [32289] = "A"; [32290] = "A";
+ [32292] = "A"; [32295] = "A"; [32296] = "A"; [32297] = "A"; [32345] = "A"; [33176] = "A";
+ [33182] = "A"; [33184] = "A"; [37011] = "A"; [37015] = "A"; [39798] = "A"; [39800] = "A";
+ [39801] = "A"; [39802] = "A"; [39803] = "A"; [40192] = "A"; [41513] = "A"; [41514] = "A";
+ [41515] = "A"; [41516] = "A"; [41517] = "A"; [41518] = "A"; [43810] = "A"; [43927] = "A";
+ [44151] = "A"; [44153] = "A"; [44221] = "A"; [44229] = "A"; [44317] = "A"; [44744] = "A";
+ [46197] = "A"; [46199] = "A"; [49193] = "A"; [51960] = "A"; [54729] = "A"; [55164] = "A";
+ [58615] = "A"; [59567] = "A"; [59568] = "A"; [59569] = "A"; [59570] = "A"; [59571] = "A";
+ [59650] = "A"; [59961] = "A"; [59976] = "A"; [59996] = "A"; [60002] = "A"; [60021] = "A";
+ [60024] = "A"; [60025] = "A"; [61229] = "A"; [61230] = "A"; [61294] = "A"; [61309] = "A";
+ [61442] = "A"; [61444] = "A"; [61446] = "A"; [61451] = "A"; [61996] = "A"; [61997] = "A";
+ [62048] = "A"; [63796] = "A"; [63844] = "A"; [63956] = "A"; [63963] = "A"; [64927] = "A";
+ [65439] = "A"; [66087] = "A"; [66088] = "A"; [67336] = "A"; [69395] = "A"; [71342] = "A";
+ [71810] = "A"; [72807] = "A"; [72808] = "A"; [74856] = "A"; [75596] = "A"; [75973] = "A";
+ [88331] = "A"; [88335] = "A"; [88718] = "A"; [88741] = "A"; [88742] = "A"; [88744] = "A";
+ [88746] = "A"; [88990] = "A"; [93623] = "A";
+
+ -- special mounts
+ [48025] = "AG"; -- headless horseman's mount
+ [72286] = "AG"; -- invincible (king lichy's mount)
+ [75614] = "AG"; -- celestial steed
+ [64731] = "SV"; -- sea turtle
+ [25953] = "Q"; -- blue qiraji battle tank
+ [26054] = "Q"; -- red qiraji battle tank
+ [26055] = "Q"; -- yellow qiraji battle tank
+ [26056] = "Q"; -- green qiraji battle tank
+ [26656] = "GQ"; -- black qiraji battle tank
+ [92155] = "GQ"; -- ultramarine qiraji battle tank
+ [75207] = "V"; -- abyssal seahorse
+};
+
+function MyLilPony.IsGroundMount(spellId)
+ local entry = MyLilPony_Mounts[spellId];
+ return entry ~= nil and string.match(entry, "G");
+end
+
+function MyLilPony.IsFlyingMount(spellId)
+ local entry = MyLilPony_Mounts[spellId];
+ return entry ~= nil and string.match(entry, "A");
+end
+
+function MyLilPony.IsAquaticMount(spellId)
+ local entry = MyLilPony_Mounts[spellId];
+ return entry ~= nil and string.match(entry, "S");
+end
+
+function MyLilPony.IsAhnQirajMount(spellId)
+ local entry = MyLilPony_Mounts[spellId];
+ return entry ~= nil and string.match(entry, "Q");
+end
+
+function MyLilPony.IsVashjirMount(spellId)
+ local entry = MyLilPony_Mounts[spellId];
+ return entry ~= nil and string.match(entry, "V");
+end
diff -r f6a1d182682e -r 7dfbf42c2d60 libMyLilPony/libMyLilPony_mountFunctions.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libMyLilPony/libMyLilPony_mountFunctions.lua Mon Apr 04 04:43:05 2011 +0000
@@ -0,0 +1,231 @@
+-- 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 .
+
+-- API functions for calling mounts
+
+function MyLilPony.CallMount()
+ local countMounts = GetNumCompanions("MOUNT");
+ if countMounts > 0 then
+ local i = random(1, countMounts);
+ local _, _, _, _, summoned = GetCompanionInfo("MOUNT", i);
+ MyLilPony.CallCompanion("MOUNT", i, not summoned);
+ return true;
+ end
+ return false;
+end
+
+function MyLilPony.CallFlyingMount()
+ local filter = function (i)
+ local _, _, id, _, summoned = GetCompanionInfo("MOUNT", i);
+ return not summoned and MyLilPony.IsFlyingMount(id);
+ end
+ return MyLilPony.CallMountByFilter(filter);
+end
+
+function MyLilPony.CallGroundMount()
+ local filter = function (i)
+ local _, _, id, _, summoned = GetCompanionInfo("MOUNT", i);
+ return not summoned and MyLilPony.IsGroundMount(id);
+ end
+ return MyLilPony.CallMountByFilter(filter);
+end
+
+function MyLilPony.CallAquaticMount()
+ local filter = function (i)
+ local _, _, id, _, summoned = GetCompanionInfo("MOUNT", i);
+ return not summoned and MyLilPony.IsAquaticMount(id);
+ end
+ return MyLilPony.CallMountByFilter(filter);
+end
+
+function MyLilPony.CallMountBySlot(slotNumber)
+ local countMounts = GetNumCompanions("MOUNT");
+ if slotNumber > 0 and slotNumber < countMounts+1 then
+ local _, _, _, _, summoned = GetCompanionInfo("MOUNT", slotNumber);
+ MyLilPony.CallCompanion("MOUNT", slotNumber, not summoned);
+ return true;
+ end
+ return false;
+end
+
+function MyLilPony.CallMountByName(mountName)
+ local result = false;
+ local countMounts = GetNumCompanions("MOUNT");
+ for i = 1, countMounts do
+ local _, name, _, _, summoned = GetCompanionInfo("MOUNT", i);
+ if name == mountName then
+ MyLilPony.CallCompanion("MOUNT", i, not summoned);
+ result = true;
+ do break end
+ end
+ end
+ return result;
+end
+
+function MyLilPony.CallMountByPattern(mountNamePattern)
+ local filter = function (i)
+ local _, name, _, _, summoned = GetCompanionInfo("MOUNT", i);
+ return not summoned and MyLilPony.StringMatchIgnoreCase(name, mountNamePattern);
+ end
+ return MyLilPony.CallMountByFilter(filter);
+end
+
+function MyLilPony.CallMountById(id)
+ local result = false;
+ local countMounts = GetNumCompanions("MOUNT");
+ for i = 1, countMounts do
+ local creatureId, _, spellId, _, summoned = GetCompanionInfo("MOUNT", i);
+ if id == creatureId or id == spellId then
+ MyLilPony.CallCompanion("MOUNT", i, not summoned);
+ result = true;
+ do break end
+ end
+ end
+ return result;
+end
+
+function MyLilPony.CallMountBySpell(spellId)
+ local result = false;
+ local countMounts = GetNumCompanions("MOUNT");
+ for i = 1, countMounts do
+ local _, _, id, _, summoned = GetCompanionInfo("MOUNT", i);
+ if id == spellId then
+ MyLilPony.CallCompanion("MOUNT", i, not summoned);
+ result = true;
+ do break end
+ end
+ end
+ return result;
+end
+
+function MyLilPony.CallMountByCreature(creatureId)
+ local result = false;
+ local countMounts = GetNumCompanions("MOUNT");
+ for i = 1, countMounts do
+ local id, _, _, _, summoned = GetCompanionInfo("MOUNT", i);
+ if id == creatureId then
+ MyLilPony.CallCompanion("MOUNT", i, not summoned);
+ result = true;
+ do break end
+ end
+ end
+ return result;
+end
+
+function MyLilPony.CallMountByMatch(unit)
+ local result = false;
+ local unitBuffs = MyLilPony.GetUnitBuffs(unit);
+ local countMounts = GetNumCompanions("MOUNT");
+ for i = 1, countMounts do
+ local _, _, id, _, summoned = GetCompanionInfo("MOUNT", i);
+ if unitBuffs[id] ~= nil then
+ MyLilPony.CallCompanion("MOUNT", i, not summoned);
+ result = true;
+ do break end
+ end
+ end
+ return result;
+end
+
+function MyLilPony.CallMountByFilter(filter)
+ local countMounts = GetNumCompanions("MOUNT");
+ if countMounts > 0 then
+ local results = {};
+ local countResults = 0;
+
+ for i = 1, countMounts do
+ if filter(i) then
+ countResults = countResults + 1;
+ results[countResults] = i;
+ end
+ end
+
+ if countResults > 0 then
+ local i = random(1, countResults);
+ local _, _, _, _, summoned = GetCompanionInfo("MOUNT", results[i]);
+ MyLilPony.CallCompanion("MOUNT", results[i], not summoned);
+ return true;
+ end
+ end
+ return false;
+end
+
+function MyLilPony.ListMounts()
+ local results = {};
+ local countMounts = GetNumCompanions("MOUNT");
+ for i = 1, countMounts do
+ local _, name, _, _, _ = GetCompanionInfo("MOUNT", i);
+ results[i] = name;
+ end
+ return results;
+end
+
+function MyLilPony.ListGroundMounts()
+ local results = {};
+ local countMounts = GetNumCompanions("MOUNT");
+ local x = 1;
+ for i = 1, countMounts do
+ local _, _, id, _, _ = GetCompanionInfo("MOUNT", i);
+ if MyLilPony.IsGroundMount(id) then
+ results[x] = name;
+ x = x + 1;
+ end
+ end
+ return results;
+end
+
+function MyLilPony.ListFlyingMounts()
+ local results = {};
+ local countMounts = GetNumCompanions("MOUNT");
+ local x = 1;
+ for i = 1, countMounts do
+ local _, _, id, _, _ = GetCompanionInfo("MOUNT", i);
+ if MyLilPony.IsFlyingMount(id) then
+ results[x] = name;
+ x = x + 1;
+ end
+ end
+ return results;
+end
+
+function MyLilPony.ListAquaticMounts()
+ local results = {};
+ local countMounts = GetNumCompanions("MOUNT");
+ local x = 1;
+ for i = 1, countMounts do
+ local _, _, id, _, _ = GetCompanionInfo("MOUNT", i);
+ if MyLilPony.IsAquaticMount(id) then
+ results[x] = name;
+ x = x + 1;
+ end
+ end
+ return results;
+end
+
+function MyLilPony.ListMountsByPattern(mountNamePattern)
+ local results = {};
+ local countMounts = GetNumCompanions("MOUNT");
+ local x = 1;
+ for i = 1, countMounts do
+ local _, name, _, _, _ = GetCompanionInfo("MOUNT", i);
+ if MyLilPony.StringMatchIgnoreCase(name, mountNamePattern) then
+ results[x] = name;
+ x = x + 1;
+ end
+ end
+ return results;
+end
+
diff -r f6a1d182682e -r 7dfbf42c2d60 libMyLilPony/readme.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libMyLilPony/readme.txt Mon Apr 04 04:43:05 2011 +0000
@@ -0,0 +1,28 @@
+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 .
+
+=====================================================================
+
+To use libMyLilPony in your own addon, add the following lines
+to your TOC *in this order*, before you add any scripts that will
+call libMyLilPony. Adjust the path if necessary - the following
+case assumes you put the library in a subfolder called libMyLilPony
+
+# libMyLilPony 1.0.0
+libMyLilPony\libMyLilPony.lua
+libMyLilPony\libMyLilPony_mountData.lua
+libMyLilPony\libMyLilPony_mountFunctions.lua
+libMyLilPony\libMyLilPony_miscFunctions.lua
\ No newline at end of file
diff -r f6a1d182682e -r 7dfbf42c2d60 readme.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/readme.txt Mon Apr 04 04:43:05 2011 +0000
@@ -0,0 +1,17 @@
+MyLilPony
+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 .
+
+=====================================================================