Created
October 16, 2009 12:11
-
-
Save yaroot/211778 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
local function GetValidChannel(num) | |
local i = 0 | |
while true do | |
i = i + 1 | |
if i > 10 then return end | |
num = num + 1 | |
if num > 10 then | |
num = 1 | |
end | |
if select(2, GetChannelName(i)) then | |
return num | |
end | |
end | |
end | |
function ChatEdit_OnTabPressed(self) | |
local chatType = self:GetAttribute('chatType') | |
local channelTarget = self:GetAttribute('channelTarget') | |
local inBG = UnitInBattleground('player') and true | |
local inRaid = GetRealNumRaidMembers() > 0 and true | |
local inParty = GetRealNumPartyMembers() > 0 and true | |
local inGuild = IsInGuild() and true | |
local setType | |
if chatType == 'CHANNEL' then | |
local channelNum = GetValidChannel(channelTarget) | |
if channelNum then | |
setType = chatType | |
self:SetAttribute('channelTarget', channelNum) | |
end | |
else | |
if chatType == 'SAY' then | |
setType = inBG and 'BATTLEGROUND' or inRaid and 'RAID' or inParty and 'PARTY' or inGuild and 'GUILD' or 'SAY' | |
elseif chatType == 'BATTLEGROUND' then | |
setType = inRaid and 'RAID' or inParty and 'PARTY' or inGuild and 'GUILD' or 'SAY' | |
elseif chatType == 'RAID' then | |
setType = inParty and 'PARTY' or inGuild and 'GUILD' or 'SAY' | |
elseif chatType == 'PARTY' then | |
setType = inGuild and 'GUILD' or 'SAY' | |
elseif chatType == 'GUILD' then | |
setType = 'OFFICER' | |
elseif chatType == 'OFFICER' then | |
setType = 'SAY' | |
end | |
end | |
if setType then | |
self:SetAttribute('chatType', setType) | |
ChatEdit_UpdateHeader(self) | |
else | |
ChatEdit_SecureTabPressed(self) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment