/trunk/EMLib
--[[ |
EV's Mod Library by EVmaker, v0.08: |
EV's Mod Library by EVmaker, v0.09: |
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 |
]]-- |
-- Declares the locals |
local EML_Version = "0.08"; |
local EML_Version = "0.09"; |
local debugMode = false; |
local EML_supportedMods = { |
["Looter"] = true, |
return itemPrice; |
end |
-- Gets item tooltip information |
function EML_toolInfo(arg,from) |
local itemLink; |
local itemArray; |
if (GameTooltip:IsShown()) then |
local name; |
name, itemLink = GameTooltip:GetItem(); |
elseif (ItemRefTooltip:IsShown()) then |
local name; |
name, itemLink = ItemRefTooltip:GetItem(); |
end |
if (itemLink) then |
itemArray = EML_getInfo(itemLink); |
end |
if (itemLink) then |
if (arg == "info") then |
EMLChat(tostring(itemLink)..", ID: "..itemArray["ID"]..", Stack Size: "..itemArray["StackCount"],"chat",from) |
else |
return itemArray; |
end |
else |
EMLChat("ID Failed.","chat",from) |
return nil; |
end |
end |
-- Returns GetItemInfo in a easily accessible table |
function EML_getInfo(arg) |
local itemArray; |
local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture, itemPrice = GetItemInfo(arg) |
if (itemName) then |
local _,itemID = EML_Parser(itemLink); |
itemArray = { |
["Name"] = itemName, |
["ID"] = itemID, |
["Link"] = itemLink, |
["Rarity"] = itemRarity, |
["ILevel"] = itemLevel, |
if (what == "new") then |
table.insert(where,"StartDontRemove") |
else |
for index,value in pairs(where) do |
if (type(index) == "number") then |
table.insert(where,what) |
return nil; |
elseif (type(index) == "string") then |
where[theValue] = true |
return nil; |
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 |
end |
table.insert(where,what) |
return true; |
else |
if (debugMode) then EMLChat("Not given a table.","chat","EML","red") end |
end |
end |
end |
end |
end |
for index,value in pairs(where) do |
if (value == true) then |
if (index == what) then |
where[index]=nil; |
end |
if (index == what) then |
where[index]=nil; |
end |
end |
end |
-- Copies a table for safe resetting or other uses |
function EML_copyTable(arg) |
local newTable = {}; |
for index,value in pairs(arg) do |
newTable[index] = value; |
local newTable; |
if (type(arg) == "table") then |
newTable = {}; |
for index,value in pairs(arg) do |
newTable[index] = value; |
end |
end |
return newTable; |
end |
isFound=true; |
end |
end |
else |
if (debugMode) then EMLChat("No table for FindTable","chat","EML") end |
end |
return isFound; |
end |
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; |
return version, build, tocversion; |
end |
-- Prints or returns the current WoW zone information |
function EML_zoneInfo(what,where) |
local zoneName = tostring(GetZoneText()); |
local subZoneName = tostring(GetSubZoneText()); |
end |
if (debugMode) then |
for i=0, #(bagsName) do |
EMLChat("Bag Name: "..tostring(bagsName[i])..", Bag Type: "..(bagsType[i])..", Bag Slots: "..tostring(bagsSlots[i])..", Free Slots: "..tostring(bagsFree[i]),"chat",where) |
EMLChat("Bag Name: "..tostring(bagsName[i])..", Bag Type: "..tostring(bagsType[i])..", Bag Slots: "..tostring(bagsSlots[i])..", Free Slots: "..tostring(bagsFree[i]),"chat",where) |
end |
end |
return bagsName,bagsType,bagsSlots,bagsFree; |
## Interface: 30100 |
## Interface: 30200 |
## Title: EMLib |
## Notes: EV's Mod Library, contains commonly used functions across his mods. |
## Author: EVmaker |