I didn't feel like adding a bunch of FileWriteLines so I just edited the .lua file directly. Just don't press the "Addon" button again.
BattlePad.lua
Code:
function BattlePad_OnLoad(self)
self:RegisterEvent("PLAYER_DEAD");
self:RegisterEvent("UPDATE_BATTLEFIELD_STATUS");
end
function BattlePad_OnEvent(self, event, ...)
if ( event == "PLAYER_DEAD" ) then
RepopMe();
end
if ( event == "UPDATE_BATTLEFIELD_STATUS" ) then
local index = nil;
isinbg = 0;
for i=1, MAX_BATTLEFIELD_QUEUES, 1 do
local status,mapname,instanceID = GetBattlefieldStatus(i);
if (status == "confirm") then
index = i;
end
if (status == "active") then
isinbg = 1;
break;
end
if (status == "none") then
isinbg = 0;
end
end
if ( index ~= nil and isinbg == 0 and not InBG) then
BattlePad__wait(5, AcceptBattlefieldPort, index, true);
end
if GetBattlefieldWinner() then
BattlePad__wait(5, LeaveBattlefield);
end
end
end
local waitTable = {};
local waitFrame = nil;
function BattlePad__wait(delay, func, ...)
if(type(delay)~="number" or type(func)~="function") then
return false;
end
if(waitFrame == nil) then
waitFrame = CreateFrame("Frame","WaitFrame", UIParent);
waitFrame:SetScript("onUpdate",function (self,elapse)
local count = #waitTable;
local i = 1;
while(i<=count) do
local waitRecord = tremove(waitTable,i);
local d = tremove(waitRecord,1);
local f = tremove(waitRecord,1);
local p = tremove(waitRecord,1);
if(d>elapse) then
tinsert(waitTable,i,{d-elapse,f,p});
i = i + 1;
else
count = count - 1;
f(unpack(p));
end
end
end);
end
tinsert(waitTable,{delay,func,{...}});
return true;
end