WoWInterface SVN PVPTimer

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk/EMLib
    from Rev 3 to Rev 4
    Reverse comparison

Rev 3 → Rev 4

EMLib.toc
1,4 → 1,4
## Interface: 30200
## Interface: 30300
## Title: EMLib
## Notes: EV's Mod Library, contains commonly used functions across his mods.
## Author: EVmaker
EMLib.lua
1,13 → 1,15
--[[
EV's Mod Library by EVmaker, v0.09:
EV's Mod Library by EVmaker, v0.13:
 
After getting tired of copying often used functions (such as printing to chat) over and over after each mod I work on,
I decided to move all the most commonly used functions into a general library which I can have as a dependency for
each of my mods and simply have them all use it instead of duplicating the code for every mod.
 
Support for Levelator by SJones321
]]--
 
-- Declares the locals
local EML_Version = "0.09";
local EML_Version = "0.13";
local debugMode = false;
local EML_supportedMods = {
["Looter"] = true,
19,6 → 21,10
["QuickThreatDisplay"] = true,
["SimpleViperWarning"] = true,
["PVPTimer"] = true,
["SkillsPayBills"] = true,
["HealthPercents"] = true,
["Inviter"] = true,
["Levelator"] = true,
["EVTestMod"] = true
}
local EML_Colors = {
28,10 → 34,22
["teal"] = {0, 150, 89},
["green"] = {20, 150, 10},
["grassgreen"] = {50,150,50},
["darkgreen"] = {5,107,0},
["yellow"] = {255, 255, 0},
["white"] = {255, 255, 255},
["black"] = {0, 0, 0}
}
local EML_availColors = {
[1] = "red",
[2] = "blue",
[3] = "cyan",
[4] = "teal",
[5] = "green",
[6] = "grassgreen",
[7] = "yellow",
[8] = "white",
[9] = "black"
}
local EML_HTMLColors = {
["orange"] = "|cFFFF8000",
["purple"] = "|cFFA335EE",
180,6 → 198,7
function EML_getInfo(arg)
local itemArray;
local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture, itemPrice = GetItemInfo(arg)
local itemCount = GetItemCount(arg);
if (itemName) then
local _,itemID = EML_Parser(itemLink);
itemArray = {
191,6 → 210,7
["MinLevel"] = itemMinLevel,
["Type"] = itemType,
["SubType"] = itemSubType,
["ItemCount"] = itemCount,
["StackCount"] = itemStackCount,
["EquipLoc"] = itemEquipLoc,
["Texture"] = itemTexture,
203,39 → 223,47
-- Adds a value to a table
function EML_addTable(what,where)
local theValue = tostring(what);
if (what == "new") then
table.insert(where,"StartDontRemove")
else
if (type(where) == "table") then
for index,value in pairs(where) do
if (type(index) == "number") then
table.insert(where,what)
return true;
elseif (type(index) == "string") then
where[theValue] = true;
return true;
end
if (type(where) == "table") then
for index,value in pairs(where) do
if (type(index) == "number") then
table.insert(where,what)
return true;
elseif (type(index) == "string") then
where[theValue] = true;
return true;
end
table.insert(where,what)
return true;
else
if (debugMode) then EMLChat("Not given a table.","chat","EML","red") end
end
table.insert(where,what)
return true;
else
if (debugMode) then EMLChat("Not given a table.","chat","EML","red") end
return nil;
end
if (theValue == "new") then
EMLChat("Something hasn't been updated to use the new table add yet.","chat","EML","red")
end
end
 
-- Removes a value from a table
function EML_remTable(what,where)
for index,value in pairs(where) do
if (value == what) then
table.remove(where,index)
local removedVal = false;
if (type(where) == "table") then
for index,value in pairs(where) do
if (value == what) then
table.remove(where,index)
removedVal = true;
end
end
end
for index,value in pairs(where) do
if (index == what) then
where[index]=nil;
for index,value in pairs(where) do
if (index == what) then
where[index]=nil;
removedVal = true;
end
end
else
if (debugMode) then EMLChat("RemTable Not given a table.","chat","EML","red") end
end
return removedVal;
end
 
-- Clears an array (table)
266,8 → 294,20
isFound=true;
end
end
for index,value in pairs(where) do
if (type(value) == "table") then
for index2,value2 in pairs(value) do
if (value2 == what) then
isFound = true;
elseif (index2 == what) then
isFound=true;
end
end
end
end
else
if (debugMode) then EMLChat("No table for FindTable","chat","EML") end
return nil;
end
return isFound;
end
280,28 → 320,22
return value;
elseif (what == value) then
return index;
elseif (type(value) == "table") then
for index2,value2 in pairs(value) do
if (what == index2) then
return value2;
elseif (what == value2) then
return index2;
end
end
end
end
else
if (debugMode) then EMLChat("No table for GetTable","chat","EML") end
return nil;
end
end
 
-- Sets a table value
function EML_setTable(what,where,to)
if (type(to) == "table") then
for index,value in pairs(to) do
if (where == index) then
to[where] = what;
elseif (where == value) then
to[index] = what
end
end
else
if (debugMode) then EMLChat("No table for SetTable","chat","EML") end
end
end
 
-- Makes sure settings are in one array from another array
function EML_mergeTable(arrayTo,arrayFrom)
local newArray;
319,6 → 353,25
return newArray;
end
 
-- Returns if a table is an empty table or not
function EML_isEmpty(arg)
local isEmpty = true;
if (type(arg) == "table") then
if (#(arg) < 1) then
for index,value in pairs(arg) do
if (index ~= nil) then
isEmpty = false;
end
end
else
isEmpty = false;
end
else
return nil;
end
return isEmpty;
end
 
-- Display arrays or variables
function EML_Display(arg,from)
local displayVar;
355,8 → 408,8
EMLChat("Item "..index.." is: "..value,"chat",from)
end
end
end
if (type(arg) == "string" or type(arg) == "boolean" or type(arg) == "number") or (arg == nil) then
else
-- if (type(arg) == "string" or type(arg) == "boolean" or type(arg) == "number") or (arg == nil) then
if (type(arg) == "boolean") then
if (arg) then
displayVar = "true"
374,6 → 427,18
end
end
 
-- Displays a normal table in exact order
function EML_displayNormal(arg,from)
if (type(arg) == "table") then
if (#(arg) > 0) then
for i=1,#(arg) do
local tempVar = tostring(arg[i]);
EMLChat(i..": "..tempVar,"chat",from)
end
end
end
end
 
-- Extracts an integrated array
function EML_splitTwo(what)
local val1,val2;
385,6 → 450,8
val2 = value;
end
end
else
if (debugMode) then EMLChat("SplitTwo not given a table.","chat","EML","red") end
end
return val1,val2;
end
434,6 → 501,13
return theColor;
end
 
-- Lists availible colors in EML
function EML_listColors(from)
EMLChat("Availible Colors:","chat",from,"teal")
EML_displayNormal(EML_availColors,from)
EMLChat("----","plainchat",from,"teal")
end
 
-- EML frame toggler
function EMLFrame_Toggle(place,what)
if (type(place) == "string") then
479,8 → 553,14
-- Prints or returns the current WoW build information
function EML_buildInfo(what,where)
local version, build, thedate, tocversion = GetBuildInfo()
local buildInfo = {
["Version"] = version,
["Build"] = build,
["Date"] = thedate,
["TOC"] = tocversion,
}
if (debugMode) or (what == "info") then EMLChat("WoW Version: "..version..", Build: "..build..", TOC Version: "..tocversion,"chat",where) end
return version, build, tocversion;
return buildInfo;
end
 
-- Prints or returns the current WoW zone information