WoWInterface SVN PVPTimer

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk
    from Rev 1 to Rev 2
    Reverse comparison

Rev 1 → Rev 2

PVPTimer/PVPTimer.lua New file
0,0 → 1,241
--[[
PVP Timer 0.01b by EVmaker
 
A simple mod to display the remaining time left on the players flagged PVP timer either in its own window,
or in a LDB Displayer (Titan, Fubar, etc..)
]]--
 
-- Declare the locals
local PVPT_EML = "PVPTimer";
local debugMode = false;
local PVPT_updateInterval = 1.0;
local PVPT_defaultSettings = {
["Version"] = "0.01b",
["OnOff"] = true,
["ShowWindow"] = true
}
local playFaction, _ = UnitFactionGroup("player");
local factionColors = {
["Red"] = EML_getColor("red"),
["Blue"] = EML_getColor("blue"),
["Yellow"] = EML_getColor("yellow")
}
local backR,backG,backB,textR,textG,textB;
if (playFaction == "Horde") then
backR,backG,backB = EML_splitTable(factionColors.Red);
textR,textG,textB = EML_splitTable(factionColors.Yellow);
else
backR,backG,backB = EML_splitTable(factionColors.Blue);
textR,textG,textB = EML_splitTable(factionColors.Yellow);
end
 
-- Declare the global variables
PVPT_whatTimer = "wait";
PVPT_Settings = {
["Version"] = "0.01b";
["OnOff"] = true,
["ShowWindow"] = true
}
 
-- Setup stuff
function PVPT_OnLoad()
this:RegisterEvent("PLAYER_ENTERING_WORLD");
this:RegisterEvent("UNIT_FACTION");
this:RegisterEvent("CHAT_MSG_SYSTEM");
SLASH_PVPT1 = "/pvptimer"
SLASH_PVPT2 = "/pvpt"
SlashCmdList["PVPT"] = function(msg)
PVPT_SlashHandler(msg);
end
EMLChat("PVP Timer "..PVPT_defaultSettings["Version"].." loaded","plainchat",PVPT_EML,"teal")
end
 
function PVPT_OnEvent(event)
if (event == "PLAYER_ENTERING_WORLD") then
if (PVPT_Settings["OnOff"]) then
PVPT_updatePVP()
end
if (PVPT_Settings["Version"] ~= PVPT_defaultSettings["Version"]) then
if (debugMode) then EMLChat("Version is different.","chat",PVPT_EML) end
PVPT_Reset("version")
else
if (debugMode) then EMLChat("Version is the same.","chat",PVPT_EML) end
end
end
if (event == "CHAT_MSG_SYSTEM" and PVPT_Settings["OnOff"]) then
if (arg1 == "You will be unflagged for PvP combat after five minutes of non-PvP action in friendly territory.") then
PVPT_whatTimer = "wait";
PVPT_updatePVP()
end
end
if (event == "UNIT_FACTION" and arg1 == "player" and PVPT_Settings["OnOff"]) then
PVPT_whatTimer = "wait";
PVPT_updatePVP()
end
end
 
function PVPT_SlashHandler(theMsg)
msg = strtrim(strlower(theMsg or ""))
if msg == "version" then
EMLChat("This version of PVP Timer is: "..PVPT_defaultSettings["Version"],"chat",PVPT_EML)
elseif msg == "debug" then
if (debugMode) then
debugMode = false;
EMLChat("Toggling debug mode off","chat",PVPT_EML)
else
debugMode = true;
EMLChat("Toggling debug mode on","chat",PVPT_EML)
end
elseif msg == "reset" then
PVPT_Reset()
elseif msg == "window" then
PVPT_whatTimer = "wait";
local WindowStatus = EMLFrame_Toggle("PVPT1");
if (WindowStatus == "show") then
EMLFrame_Toggle("PVPT_Timer","open")
else
EMLFrame_Toggle("PVPT_Timer","close")
end
elseif msg == "toggle pvptimer" then
if (PVPT_Settings["OnOff"]) then
PVPT_Settings["OnOff"]=false;
EMLChat("PVP Timer toggled off.","chat",PVPT_EML)
else
PVPT_Settings["OnOff"]=true;
EMLChat("PVP Timer toggled on.","chat",PVPT_EML)
end
elseif msg == "toggle window" then
if (PVPT_Settings["ShowWindow"]) then
PVPT_Settings["ShowWindow"]=false;
EMLChat("PVP Timer's window will not be shown.","chat",PVPT_EML)
else
PVPT_Settings["ShowWindow"]=true;
EMLChat("PVP Timer's window will be shown.","chat",PVPT_EML)
end
elseif msg == "toggle status" then
if (PVPT_Settings["OnOff"]) then
EMLChat("PVP Timer is on.","chat",PVPT_EML,"green")
else
EMLChat("PVP Timer is off.","chat",PVPT_EML,"red")
end
if (PVPT_Settings["ShowWindow"]) then
EMLChat("PVP Timer's window will be shown.","chat",PVPT_EML,"green")
else
EMLChat("PVP Timer's window will not be shown.","chat",PVPT_EML,"red")
end
elseif msg == "test1" then
PVPT_testFunction()
elseif msg == "authors" then
EMLChat("evmaker, the Lua Coder.","chat",PVPT_EML)
elseif msg == "evmaker" then
EMLChat("EVmaker codes the Lua (only) part of the mod.","chat",PVPT_EML)
else
EMLChat("Valid Options:","chat",PVPT_EML)
EMLChat("toggle status (shows the status of PVP Timer's settings)","chat",PVPT_EML)
EMLChat("toggle pvptimer (turns PVP Timer on or off)","chat",PVPT_EML)
EMLChat("toggle window (turns whether to display the timer window on or off)","chat",PVPT_EML)
EMLChat("-----------------","chat",PVPT_EML)
EMLChat("Other Commands:","chat",PVPT_EML)
EMLChat("window (opens or closes the PVP Timer window)","chat",PVPT_EML)
EMLChat("version (displays PVP Timers version)","chat",PVPT_EML)
EMLChat("-----------------","chat",PVPT_EML)
EMLChat("Authors, slashes for them as well.","chat",PVPT_EML)
end
end
 
-- Functions for testing code
function PVPT_testFunction(arg)
EMLChat("Test Function 1:","chat",PVPT_EML,"teal")
local testArray = PVPT_pvpCheck();
if (testArray) then
EMLChat("PVP Timer is running, with "..testArray.Minutes.." minutes and "..testArray.Seconds.." seconds left.","chat",PVPT_EML)
end
end
-- End of test functions
 
-- Resets and updates settings
function PVPT_Reset(arg)
local localSettings = EML_copyTable(PVPT_defaultSettings);
PVPT_Settings=EML_mergeTable(PVPT_Settings,localSettings);
if (arg == "version") then
PVPT_Settings["Version"]=localSettings["Version"];
EMLChat("Version is changed, resetting and updating settings.","chat",PVPT_EML)
else
EMLChat("Everythings reset","chat",PVPT_EML)
EML_clearTable(PVPT_Settings)
PVPT_Settings=localSettings;
end
end
 
-- Returns the remaining time on the players pvp timer or nil (doesn't have one)
function PVPT_getPVP(arg)
local pvpArray = {};
local isPvP = IsPVPTimerRunning();
if (isPvP) then
pvpArray["Running"] = IsPVPTimerRunning();
pvpArray["TimeLeft"] = tonumber(floor(GetPVPTimer()/1000));
pvpArray["Minutes"] = tonumber(floor(pvpArray["TimeLeft"]/60));
pvpArray["Seconds"] = tonumber(pvpArray["TimeLeft"]%60);
else
if (PVPT_whatTimer == "wait") then EMLFrame_Toggle("PVPT_Timer","open") end
return nil;
end
return pvpArray;
end
 
-- Sets up the PVP Timer window
function PVPT_displayWindow(arg)
if (arg == "open" and PVPT_Settings["OnOff"] and PVPT_Settings["ShowWindow"]) then
EMLFrame_Toggle("PVPT1","open")
EMLFrame_Toggle("PVPT_Timer","open")
elseif (arg == "close" and PVPT_Settings["OnOff"]) then
EMLFrame_Toggle("PVPT1","close")
EMLFrame_Toggle("PVPT_Timer","open")
else
EMLFrame_Toggle("PVPT_Timer","open")
end
end
 
-- Sets the display's information
function PVPT_updatePVP()
local pvpArray = PVPT_getPVP();
if (pvpArray) then
local theText = tostring(pvpArray.Minutes.."."..pvpArray.Seconds);
PVPT_Color:SetVertexColor(backR,backG,backB);
PVPT_textTime:SetText(theText)
PVPT_textTime:SetTextColor(textR,textG,textB)
PVPT_displayWindow("open")
else
PVPT_Color:SetVertexColor(1,1,1);
PVPT_textTime:SetText("0")
PVPT_textTime:SetTextColor(1,1,0);
PVPT_displayWindow("close")
end
end
 
-- Timer to delay actions
function PVPT_waitTimer(self,elapsed,whatDo)
local isPvP = IsPVPTimerRunning();
self.TimeSinceLastUpdate = self.TimeSinceLastUpdate + elapsed;
if (whatDo == "normal") then
if (not isPvP) then
self.TimeSinceLastUpdate = 0;
PVPT_Timer:Hide()
PVPT_updatePVP()
PVPT_whatTimer = "wait";
if (debugMode) then EMLChat("Normal Ran.","chat",PVPT_EML) end
end
elseif (whatDo == "wait") then
if (self.TimeSinceLastUpdate > (PVPT_updateInterval*2)) then
self.TimeSinceLastUpdate = 0;
PVPT_updatePVP()
PVPT_whatTimer = "normal";
if (debugMode) then EMLChat("Wait Ran.","chat",PVPT_EML) end
end
end
if (self.TimeSinceLastUpdate > PVPT_updateInterval and whatDo == "normal") then
self.TimeSinceLastUpdate = 0;
PVPT_updatePVP()
end
end
-- End of code
\ No newline at end of file
PVPTimer/PVPTimer.toc New file
0,0 → 1,7
## Interface: 30100
## Title: PVP Timer
## Notes: Displays the pvp flag time remaining in its own window, or via LDB.
## Dependencies: EMLib
## Author: EVmaker
## SavedVariablesPerCharacter: PVPT_Settings
PVPTimer.xml
\ No newline at end of file
PVPTimer/readme.txt New file
0,0 → 1,40
Readme for PVP Timer, a World of Warcraft Mod.
----
 
Version 0.1b
PVP Timer by EVmaker
 
A simple mod to display the remaining time left on the players flagged PVP timer either in its own window,
or in a LDB Displayer (Titan, Fubar, etc.., in the next release). PVP Timer's window can be placed wherever
you wish and it will remember its location, it can be opened manually (/pvpt window) or open itself
automatically when your pvp countdown starts (if showing its window is on, which is the default).
 
Commands:
/pvpt version (shows the version)
/pvpt window (opens PVP Timer's window)
/pvpt toggle {option} (see below)
Options:
/pvpt toggle status (shows what's on or off)
/pvpt toggle pvptimer (toggles PVP Timer on or off)
/pvpt toggle window (whether to automatically display its window or not)
 
A GUI for these options, and an LDB displayer will be in the next release.
----
Todos:
 
In-Line Todos:
* Add LDB (Titan Panel, Fubar, etc..) support.
* Add a basic GUI.
* Add options for customizing displayed colors.
 
Future Todo:
* TBD
 
Eternal Todos:
* Eliminate any bugs (if any)
----------------------------------------------------------------------
Changelog:
0.01b:
Initial release, has the PVP Timer window which displays the time remaining on your pvp counter, colored by faction (red and yellow
for horde, blue and yellow for alliance). Slash options for whether to show the window constantly (/pvpt toggle window) and to turn
the mod itself on or off (pvpt toggle pvptimer). Mod is also already 3.2 Compatible.
\ No newline at end of file
PVPTimer/PVPTimer.xml New file
0,0 → 1,91
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\FrameXML\UI.xsd">
<Script file="PVPTimer.lua"/>
 
<Frame name="PVPT_GeneralScripts" hidden="true">
<Scripts>
<OnLoad>
PVPT_OnLoad();
</OnLoad>
<OnEvent>
PVPT_OnEvent(event);
</OnEvent>
</Scripts>
</Frame>
 
<!-- Frame for quest timer -->
<Frame name="PVPT_Timer" hidden="true">
<Scripts>
<OnLoad>
self.TimeSinceLastUpdate = 0
</OnLoad>
<OnUpdate>
PVPT_waitTimer(self,elapsed,PVPT_whatTimer);
</OnUpdate>
</Scripts>
</Frame>
 
<Frame name="PVPT1" toplevel="true" parent="UIParent" frameStrata="DIALOG" hidden="true" enableMouse="true" movable="true">
<Size>
<AbsDimension x="50" y="45"/>
</Size>
<Anchors>
<Anchor point="CENTER"/>
</Anchors>
<Backdrop edgeFile="Interface\DialogFrame\UI-DialogBox-Border">
<EdgeSize>
<AbsValue val="20"/>
</EdgeSize>
</Backdrop>
<Layers>
<Layer level="BACKGROUND">
<Texture name="PVPT_Color">
<Size>
<AbsDimension x="40" y="35"/>
</Size>
<Anchors>
<Anchor point="CENTER">
<Offset>
<AbsDimension x="0" y="0"/>
</Offset>
</Anchor>
</Anchors>
<Color r="1.0" g="1.0" b="1.0"/>
</Texture>
</Layer>
</Layers>
<Frames>
<SimpleHTML name="PVPT_textTime">
<Size>
<AbsDimension x="40" y="35"/>
</Size>
<Anchors>
<Anchor point="CENTER">
<Offset>
<AbsDimension x="5" y="-10"/>
</Offset>
</Anchor>
</Anchors>
<FontString justifyV="CENTER" justifyH="CENTER" font="Fonts\MORPHEUS.ttf">
<FontHeight>
<AbsValue val="12"/>
</FontHeight>
<Size>
<AbsDimension x="0" y="0"/>
</Size>
</FontString>
</SimpleHTML>
</Frames>
<Scripts>
<OnLoad>
this:RegisterForDrag("LeftButton");
</OnLoad>
<OnDragStart>
this:StartMoving()
</OnDragStart>
<OnDragStop>
this:StopMovingOrSizing()
</OnDragStop>
</Scripts>
</Frame>
</Ui>
\ No newline at end of file
EMLib/EMLib.xml New file
0,0 → 1,17
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/">
 
<Script file="EMLib.lua"/>
 
<!-- Here the general scripts that have to be Executed -->
<Frame name="EML_GeneralScripts" hidden="true">
<Scripts>
<OnLoad>
EML_OnLoad();
</OnLoad>
<OnEvent>
EML_OnEvent(event);
</OnEvent>
</Scripts>
</Frame>
 
</Ui>
\ No newline at end of file
EMLib/EMLib.lua New file
0,0 → 1,506
--[[
EV's Mod Library by EVmaker, v0.08:
 
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.
]]--
 
-- Declares the locals
local EML_Version = "0.08";
local debugMode = false;
local EML_supportedMods = {
["Looter"] = true,
["UsefulExtras"] = true,
["XPGain"] = true,
["EasyShards"] = true,
["LoreMaster"] = true,
["QuickMountGather"] = true,
["QuickThreatDisplay"] = true,
["SimpleViperWarning"] = true,
["PVPTimer"] = true,
["EVTestMod"] = true
}
local EML_Colors = {
["red"] = {143, 10, 13},
["blue"] = {10, 12, 150},
["cyan"] = {16, 211, 255},
["teal"] = {0, 150, 89},
["green"] = {20, 150, 10},
["grassgreen"] = {50,150,50},
["yellow"] = {255, 255, 0},
["white"] = {255, 255, 255},
["black"] = {0, 0, 0}
}
local EML_HTMLColors = {
["orange"] = "|cFFFF8000",
["purple"] = "|cFFA335EE",
["brightblue"] = "|cFF0070DE",
["brightgreen"] = "|cFF1EFF00",
["white"] = "|cFFFFFFFF",
["close"] = "|r"
}
 
function EML_OnLoad()
SLASH_EML1 = "/eml"
SlashCmdList["EML"] = function(msg)
EML_SlashHandler(msg);
end
end
 
function EML_OnEvent(event)
-- Nothing yet
end
 
-- Handles the slash commands
function EML_SlashHandler(theMsg)
msg = strtrim(strlower(theMsg or ""))
if msg == "version" then
EMLChat("EML version: "..EML_Version,"chat","EML")
elseif strmatch(msg, "list") then
local theChoice = strmatch(msg, "list (.*)")
if (theChoice) then
if (theChoice == "supportedmods") then
EML_Display(EML_supportedMods,"EML")
end
else
EMLChat("List options: supportedmods","chat","EML")
end
elseif msg == "debug" then
if (debugMode) then
debugMode = false;
EMLChat("Debug mode off","chat","EML")
else
debugMode = true;
EMLChat("Debug mode on","chat","EML")
end
elseif msg == "build" then
EML_buildInfo("info","EML")
elseif msg == "zone" then
EML_zoneInfo("info","EML")
elseif msg == "test1" then
EML_testFunction()
else
EMLChat("EV's Mod Library Menu","chat","EML")
EMLChat("-------------------","chat","EML")
EMLChat("version, (displays version information)","chat","EML")
EMLChat("list, (choose what to list)","chat","EML")
end
end
 
-- Prints to chat with the appropriate mods message
function EMLChat(msg,place,from,colors)
local valR, valG, valB;
if (type(colors) == "table") then
valR, valG, valB = EML_splitTable(colors);
elseif (EML_findTable(colors,EML_Colors)) then
valR,valG,valB = EML_splitTable(EML_getTable(colors,EML_Colors));
else
valR, valG, valB = EML_splitTable(EML_Colors.yellow);
end
local isSupported = EML_findTable(from,EML_supportedMods);
if (place == "chat") and (not isSupported) then
if DEFAULT_CHAT_FRAME then
DEFAULT_CHAT_FRAME:AddMessage("<EML> "..msg, valR, valG, valB)
end
end
if (place == "error") and (not isSupported) then
UIErrorsFrame:AddMessage("<EML> "..msg, valR, valG, valB)
end
if (place == "error") and (isSupported) then
UIErrorsFrame:AddMessage("<"..from.."> "..msg, valR, valG, valB, 1, 10)
end
if (place == "chat") and (isSupported) then
if DEFAULT_CHAT_FRAME then
DEFAULT_CHAT_FRAME:AddMessage("<"..from.."> "..msg, valR, valG, valB)
end
end
if (place == "raid") and (isSuppported) then
RaidNotice_AddMessage(RaidWarningFrame, msg, {r=valR, g=valG, b=valB});
end
if place == "plainchat" then
if DEFAULT_CHAT_FRAME then
DEFAULT_CHAT_FRAME:AddMessage(msg, valR, valG, valB)
end
end
if place == "plainerror" then
UIErrorsFrame:AddMessage(msg, valR, valG, valB, 1, 10)
end
if (from == nil) and (place ~= "plainchat" and place ~= "plainerror") then
if DEFAULT_CHAT_FRAME then
DEFAULT_CHAT_FRAME:AddMessage("<EML> The command you just tried to use wasn't updated to use EV's Mod Library, please leave him a comment on the WoWI page of the mod this command was from.", 1, 1, 0)
end
end
end
 
-- Grabs the name from a item link
function EML_Parser(link)
local itemName,itemID;
itemName = tostring(strmatch(link, "%[(.*)%]"));
itemID = tonumber(strmatch(link, "item:(%d+)"));
return itemName,itemID;
end
 
-- Gets the value of an item by name, id or link
function EML_getPrice(link)
local itemPrice;
if (link) then
_, _, _, _, _, _, _, _, _, _, itemPrice = GetItemInfo(link)
end
return itemPrice;
end
 
function EML_getInfo(arg)
local itemArray;
local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture, itemPrice = GetItemInfo(arg)
if (itemName) then
itemArray = {
["Name"] = itemName,
["Link"] = itemLink,
["Rarity"] = itemRarity,
["ILevel"] = itemLevel,
["MinLevel"] = itemMinLevel,
["Type"] = itemType,
["SubType"] = itemSubType,
["StackCount"] = itemStackCount,
["EquipLoc"] = itemEquipLoc,
["Texture"] = itemTexture,
["Price"] = itemPrice
}
end
return itemArray;
end
 
-- Adds a value to a table
function EML_addTable(what,where)
local theValue = tostring(what);
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;
end
end
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)
end
end
for index,value in pairs(where) do
if (value == true) then
if (index == what) then
where[index]=nil;
end
end
end
end
 
-- Clears an array (table)
function EML_clearTable(arg)
arg = table.wipe(arg);
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;
end
return newTable;
end
 
-- Returns if a value is found in a table
function EML_findTable(what,where)
local isFound = false;
if (type(where) == "table") then
for index,value in pairs(where) do
if (value == what) then
isFound=true;
elseif (index == what) then
isFound=true;
end
end
end
return isFound;
end
 
-- Returns the value in a table
function EML_getTable(what,where)
if (type(where) == "table") then
for index,value in pairs(where) do
if (what == index) then
return value;
elseif (what == value) then
return index;
end
end
else
if (debugMode) then EMLChat("No table for GetTable","chat","EML") end
end
end
 
-- Makes sure settings are in one array from another array
function EML_mergeTable(arrayTo,arrayFrom)
local newArray;
if (type(arrayTo) ~= "table") or (type(arrayFrom) ~= "table") then
return nil;
else
newArray = EML_copyTable(arrayTo);
end
for index,value in pairs(arrayFrom) do
local isThere = EML_findTable(index,newArray);
if (not isThere) then
newArray[index]=value;
end
end
return newArray;
end
 
-- Display arrays or variables
function EML_Display(arg,from)
local displayVar;
if (type(arg) == "table") then
for index,value in pairs(arg) do
if type(value) == "boolean" then
if value then
value = "true"
else
value = "false"
end
end
if type(value) == "table" then
for index2,value2 in pairs(value) do
if type(value2) == "boolean" then
if value2 then
value2 = "true"
else
value2 = "false"
end
end
if (value2 ~= nil and value2 ~= "" and value2 ~= " ") then
value2 = tostring(value2)
end
if (value2 == nil or value2 == "" or value2 == " ") then
value2 = "nil"
end
EMLChat("Item is: "..value2,"chat",from)
end
end
if (value ~= "StartDontRemove") and (type(value) ~= "table") and (not debugMode) then
EMLChat("Item "..index.." is: "..value,"chat",from)
elseif (debugMode) then
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
if (type(arg) == "boolean") then
if (arg) then
displayVar = "true"
else
displayVar = "false"
end
elseif (type(arg) == "number") then
displayVar = tostring(arg)
elseif (arg == nil) then
displayVar = "nil"
else
displayVar = arg
end
EMLChat("Item is: "..displayVar,"chat",from)
end
end
 
-- Extracts an integrated array
function EML_splitTwo(what)
local val1,val2;
if (type(what) == "table") then
for index,value in pairs(what) do
if (index == 1) then
val1 = value;
elseif (index == 2) then
val2 = value;
end
end
end
return val1,val2;
end
 
-- Splits a RGB table into WoW values
function EML_splitTable(arg)
local val1, val2, val3;
if (type(arg) == "table") then
for index,value in pairs(arg) do
if (index == 1) then
val1 = tonumber(value/255);
elseif (index == 2) then
val2 = tonumber(value/255);
elseif (index == 3) then
val3 = tonumber(value/255);
end
end
end
return val1, val2, val3;
end
 
-- Splits a RGB table and returns the exact values
function EML_splitWoWTable(arg)
local val1, val2, val3;
if (type(arg) == "table") then
for index,value in pairs(arg) do
if (index == 1) then
val1 = tonumber(value);
elseif (index == 2) then
val2 = tonumber(value);
elseif (index == 3) then
val3 = tonumber(value);
end
end
end
return val1, val2, val3;
end
 
-- Returns the value of the RGB color requested
function EML_getColor(arg)
local theColor;
if (arg) then
if (EML_findTable(arg,EML_Colors)) then
theColor=EML_getTable(arg,EML_Colors);
end
end
return theColor;
end
 
-- EML frame toggler
function EMLFrame_Toggle(place,what)
if (type(place) == "string") then
local frame = getglobal(place)
if (frame) then
if (what == nil) then
if (frame:IsVisible()) then
frame:Hide()
return "hide";
else
frame:Show()
return "show";
end
return nil;
else
if (what == "open") then
frame:Show()
return "show";
else
frame:Hide()
return "hide";
end
end
end
else
if (debugMode) then EMLChat("Frame error","chat","EML","red") end
end
end
 
-- Generates random numbers
function EML_randGen(minnum,maxnum)
local randNum;
local minNum = tonumber(minnum);
local maxNum = tonumber(maxnum);
if (minNum) then
randNum=random(minNum,maxNum);
else
randNum=random(1,100);
end
return randNum;
end
 
-- Prints or returns the current WoW build information
function EML_buildInfo(what,where)
local version, build, thedate, tocversion = GetBuildInfo()
if (debugMode) or (what == "info") then EMLChat("WoW Version: "..version..", Build: "..build..", TOC Version: "..tocversion,"chat",where) end
return version, build, tocversion;
end
 
function EML_zoneInfo(what,where)
local zoneName = tostring(GetZoneText());
local subZoneName = tostring(GetSubZoneText());
if (debugMode) or (what == "info") then EMLChat("Zone: "..zoneName..", SubZone: "..subZoneName,"chat",where) end
return zoneName, subZoneName;
end
 
-- Gets bag information
function EML_bagInfo(where)
local bagsName = {};
local bagsType = {};
local bagsSlots = {};
local bagsFree = {};
for i=0, 4 do
local bagName = GetBagName(i);
local bagFree, bagType = GetContainerNumFreeSlots(i);
local numSlots = GetContainerNumSlots(i);
if (bagName) then
bagsName[i]=tostring(bagName);
bagsType[i]=tonumber(bagType);
bagsSlots[i]=tonumber(numSlots);
bagsFree[i]=tonumber(bagFree);
end
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)
end
end
return bagsName,bagsType,bagsSlots,bagsFree;
end
 
function EML_itemInfo(bagID,slotID)
local slotLink = GetContainerItemLink(bagID,slotID);
local itemName, itemNum;
if (slotLink) then itemName, itemNum = EML_Parser(slotLink); end
return itemName,itemNum;
end
 
-- Provides easy handling of colors and returning of color values from the color picker
function EML_colorPicker(arg,from)
local tempR,tempG,tempB;
local r,g,b,shortR,shortG,shortB;
local theColor = {};
if arg == "reset" then
ColorPickerFrame:SetColorRGB(1,0,0)
end
if arg == "open" then
ColorPickerFrame.func = EML_colorPicker
ColorPickerFrame:Show()
else
r, g, b = ColorPickerFrame:GetColorRGB();
tempR=math.floor(r*255);
tempG=math.floor(g*255);
tempB=math.floor(b*255);
shortR,shortG,shortB = (strsub(r,1,4)),(strsub(g,1,4)),(strsub(b,1,4));
theColor={tempR,tempG,tempB};
end
if (arg == "get") and (tempR and tempG and tempB) then
local tempArray = {tempR,tempG,tempB};
EMLChat("Red: "..tempR..", Green: "..tempG..", Blue: "..tempB,"chat",from,tempArray)
end
if (arg == "getreal") and (r and g and b) then
local tempArray = {tempR,tempG,tempB};
EMLChat("Red: "..shortR..", Green: "..shortG..", Blue: "..shortB,"chat",from,tempArray)
end
return theColor;
end
 
-- Test function
function EML_testFunction()
-- Nothing yet
end
-- End of code
\ No newline at end of file
EMLib/EMLib.toc New file
0,0 → 1,5
## Interface: 30100
## Title: EMLib
## Notes: EV's Mod Library, contains commonly used functions across his mods.
## Author: EVmaker
EMLib.xml
\ No newline at end of file