Created
October 13, 2013 15:15
-
-
Save Kruithne/6963409 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a_a = { | |
lapseTick = 7000, | |
ticks = 0, | |
currentChannel = nil | |
}; | |
function a_a.worker(frame, elapsed) | |
local self = a_a; | |
if self.ticks == self.lapseTick then | |
self.broadcast(); | |
self.ticks = 0; | |
else | |
self.ticks = self.ticks + 1; | |
end | |
end | |
function a_a.event(frame, event, prefix, msg) | |
if event == 'CHAT_MSG_ADDON' and prefix == 'a_a' then | |
local ci, ct = a_a.getChannel(); | |
if msg == ct then | |
a_a.ticks = 0; | |
end | |
end | |
end | |
function a_a.broadcast() | |
local t = GetGuildInfoText(); | |
local a = string.sub(t, string.find(t, "-AD-") + 5, string.find(t, "-ADEND-") - 2); | |
local ci, ct = a_a.getChannel(); | |
if ci ~= nil then | |
SendChatMessage(a, "CHANNEL", "COMMON", ci); | |
SendAddonMessage("a_a", ct, "GUILD"); | |
end | |
end | |
function a_a.getChannel() | |
if GetRealZoneText() == "Timeless Isle" then | |
return 1, "timeless"; | |
end | |
local c = {GetChannelList()}; | |
for ci, cn in pairs(c) do | |
if cn == "Trade" then | |
return 2, "trade"; | |
end | |
end | |
return nil, nil; | |
end | |
RegisterAddonMessagePrefix("a_a"); | |
local f = CreateFrame("frame"); | |
f:SetScript("OnUpdate", a_a.worker); | |
f:SetScript("OnEvent", a_a.event); | |
f:RegisterEvent("CHAT_MSG_ADDON"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment