Lak
04-07-2007, 01:57 AM
I am trying to revive a mod, and this mod makes and puts the playing in a specific channel it creates.
function AltaVoice_JoinVoiceChannel()
local player = UnitName("player");
local realm = GetRealmName();
AltaVoice_PlayerOfRealm = player.." of "..realm;
local _, isActive = JoinChannelByName(AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel);
if (isActive == nil)then
JoinChannelByName(AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel);
RemoveChatWindowChannel(DEFAULT_CHAT_FRAME:GetID(), AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel);
AltaVoice_ChannelName = GetChannelName(AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel);
end
AltaVoice_ChannelName = GetChannelName(AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel);
AltaVoice_JoinMasterChannel();
end
Thats the segment that is causing all the trouble and here is the whole thing for reference
BINDING_HEADER_ALTAVOICE = "AltaVoice";
BINDING_NAME_PUSHTOTALK = "Push To Talk";
-- Default Variables
AltaVoice_SVars = {};
AltaVoice_TalkTable = {};
AltaVoice_ActiveChannels = {};
AltaVoice_VolumeDipped = false;
function AltaVoice_OnLoad()
this:RegisterEvent("ADDON_LOADED");
arg1 = AltaVoice;
this:RegisterEvent("CHAT_MSG_CHANNEL");
UIErrorsFrame:AddMessage("AltaVoiceLoaded", 0, 1.0, 0, 1.0, UIERRORS_HOLD_TIME);
DEFAULT_CHAT_FRAME:AddMessage("AltaVoice : AltaVoice Loaded", 0.0, 1.0, 0.0);
AltaVoice_Language = this.language;
-- Register Slash Commands
SlashCmdList["AltaVoice"] = function(msg)
AltaVoice_SlashHandler(msg);
end
SLASH_AltaVoice1 = "/altavoice";
end
function AltaVoice_SlashHandler(msg)
if (msg == "")then
DEFAULT_CHAT_FRAME:AddMessage("AltaVoice : Slash Command List :", 0.0, 1.0, 0.0);
DEFAULT_CHAT_FRAME:AddMessage("AltaVoice : /altavoice show", 0.0, 1.0, 0.0);
DEFAULT_CHAT_FRAME:AddMessage("AltaVoice : /altavoice hide", 0.0, 1.0, 0.0);
end
if (msg == "show")then
AltaVoice_VoiceWindowTitle:Show();
end
if (msg == "hide")then
AltaVoice_VoiceWindowTitle:Hide();
AltaVoice_Menu_Title:Hide();
end
end
function AltaVoice_LoadProfile()
local player = UnitName("player");
local realm = GetCVar("realmName");
AltaVoice_PlayerOfRealm = player.." of "..realm;
if (AltaVoice_SVars[AltaVoice_PlayerOfRealm])then
AltaVoice_RefreshVisuals();
DEFAULT_CHAT_FRAME:AddMessage("AltaVoice : Loaded Profile for "..AltaVoice_PlayerOfRealm..".", 0.0, 1.0, 0.0);
else
AltaVoice_SVars[AltaVoice_PlayerOfRealm] = {};
if (IsInGuild())then
local guildName = GetGuildInfo("player");
local findSpaces = string.find(guildName, " ");
if (findSpaces)then
local starts, ends, cursor = 0,0,1;
local repairedName = "";
while (starts ~=nil)do
starts, ends = string.find(guildName, " ", cursor);
if (starts ~=nil)then
repairedName = repairedName..string.sub(guildName, cursor, starts-1);
cursor = ends +1;
else
repairedName = repairedName..string.sub(guildName, cursor);
end
end
guildName = repairedName;
end
AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel = "AltaVoice"..guildName;
else
AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel = "AltaVoice"..player;
end
AltaVoice_SVars[AltaVoice_PlayerOfRealm].SpeakListLength = 40;
AltaVoice_SVars[AltaVoice_PlayerOfRealm].ListMode = "List";
AltaVoice_SVars[AltaVoice_PlayerOfRealm].AllowInvites = true;
AltaVoice_SVars[AltaVoice_PlayerOfRealm].VolumeDip = false;
AltaVoice_SVars[AltaVoice_PlayerOfRealm].VolumeDipValues = {};
AltaVoice_SVars[AltaVoice_PlayerOfRealm].VolumeDipValues.Master = GetCVar("MasterVolume");
AltaVoice_SVars[AltaVoice_PlayerOfRealm].VolumeDipValues.Sound = GetCVar("SoundVolume");
AltaVoice_SVars[AltaVoice_PlayerOfRealm].VolumeDipValues.Music = GetCVar("MusicVolume");
AltaVoice_SVars[AltaVoice_PlayerOfRealm].VolumeDipValues.Ambience = GetCVar("AmbienceVolume");
AltaVoice_SVars[AltaVoice_PlayerOfRealm].Appearance = {};
AltaVoice_SVars[AltaVoice_PlayerOfRealm].Appearance.TalkWindow = {};
AltaVoice_SVars[AltaVoice_PlayerOfRealm].Appearance.TalkWindow.Width = 100;
AltaVoice_SVars[AltaVoice_PlayerOfRealm].Appearance.TalkWindow.Scale = 1;
DEFAULT_CHAT_FRAME:AddMessage("AltaVoice : Profile Created for "..AltaVoice_PlayerOfRealm..".", 0.0, 1.0, 0.0);
end
end
function AltaVoice_JoinVoiceChannel()
local player = UnitName("player");
local realm = GetRealmName();
AltaVoice_PlayerOfRealm = player.." of "..realm;
local _, isActive = JoinChannelByName(AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel);
if (isActive == nil)then
JoinChannelByName(AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel);
RemoveChatWindowChannel(DEFAULT_CHAT_FRAME:GetID(), AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel);
AltaVoice_ChannelName = GetChannelName(AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel);
end
AltaVoice_ChannelName = GetChannelName(AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel);
AltaVoice_JoinMasterChannel();
end
function AltaVoice_JoinVoiceChannelOnClick()
local channelName = "AltaVoice"..AltaVoice_Menu_Panel_ChannelName:GetText();
local findSpaces = string.find(channelName, " ");
if (findSpaces)then
local starts, ends, cursor = 0,0,1;
local repairedName = "";
while (starts ~=nil)do
starts, ends = string.find(channelName, " ", cursor);
if (starts ~=nil)then
repairedName = repairedName..string.sub(channelName, cursor, starts-1);
cursor = ends +1;
else
repairedName = repairedName..string.sub(channelName, cursor);
end
end
channelName = repairedName;
AltaVoice_Menu_Panel_ChannelName:SetText(repairedName);
end
AltaVoice_Menu_Panel_ChannelName:ClearFocus();
ChatFrame1.editBox:SetText("/leave "..AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel);
ChatEdit_SendText(ChatFrame1.editBox);
AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel = channelName;
AltaVoice_JoinVoiceChannel();
AltaVoice_TalkTable = {};
AltaVoice_UpdateTalkList();
end
function AltaVoice_JoinMasterChannel()
local _, isActive = JoinChannelByName("AltaVoiceMaster");
if (isActive == nil)then
JoinChannelByName("AltaVoiceMaster");
RemoveChatWindowChannel(DEFAULT_CHAT_FRAME:GetID(), "AltaVoiceMaster");
end
AltaVoice_MasterChannelID = GetChannelName("AltaVoiceMaster");
end
function AltaVoice_StartTalk()
if (AltaVoice_ChannelName == nil)then
AltaVoice_JoinVoiceChannel();
end
SendChatMessage("StartTalk", "CHANNEL", AltaVoice_Language, AltaVoice_ChannelName);
end
function AltaVoice_StopTalk()
SendChatMessage("StopTalk", "CHANNEL", AltaVoice_Language, AltaVoice_ChannelName);
end
function AltaVoice_OnEvent()
if (event == "CHAT_MSG_CHANNEL") then
if (AltaVoice_ChannelName == nil)then
AltaVoice_JoinVoiceChannel();
end
local player = arg2;
local fromChannel = arg4;
local monitorChannel = AltaVoice_ChannelName..". "..AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel;
local masterChannel = AltaVoice_MasterChannelID..". AltaVoiceMaster";
if (fromChannel == monitorChannel)then
if (arg1 == "StartTalk")then
AltaVoice_EditTalkTable(player, "talk");
if (AltaVoice_SVars[AltaVoice_PlayerOfRealm].VolumeDip)then
AltaVoice_DipVolume();
end
end
if (arg1 == "StopTalk")then
AltaVoice_EditTalkTable(player, "silent");
end
end
if (fromChannel == masterChannel)then
local msg = arg1;
local command = string.sub(msg,1,3);
local starts, ends = string.find(msg, " ", 5);
local property1 = string.sub(msg, 5, starts-1);
local property2 = string.sub(msg, ends+1);
-- recieve invite request
if ((command == "inv") and (property1 == UnitName("player")))then
AltaVoice_InviteRequestFrom = player;
AltaVoice_InviteRequestChannel = property2;
AltaVoice_InviteRequested(player, property2);
end
-- recieve invite response - Not Accepting
if ((command == "inr") and (property1 == UnitName("player")) and (property2 == "NA"))then
DEFAULT_CHAT_FRAME:AddMessage("AltaVoice : "..player.." is not accepting invites at this time.", 1.0, 0.0, 0.0);
end
-- recieve invite response - Declined
if ((command == "inr") and (property1 == UnitName("player")) and (property2 == "DE"))then
DEFAULT_CHAT_FRAME:AddMessage("AltaVoice : "..player.." declined your invitation.", 1.0, 0.0, 0.0);
end
-- recieve invite response - Already Joined
if ((command == "inr") and (property1 == UnitName("player")) and (property2 == "AJ"))then
DEFAULT_CHAT_FRAME:AddMessage("AltaVoice : "..player.." is already joined to this channel.", 1.0, 0.0, 0.0);
end
-- recieve invite response - Accepted
if ((command == "inr") and (property1 == UnitName("player")) and (property2 == "AC"))then
DEFAULT_CHAT_FRAME:AddMessage("AltaVoice : "..player.." accepted your invitation.", 0.0, 1.0, 0.0);
end
end
end
if (event == "VARIABLES_LOADED")then
AltaVoice_LoadProfile();
end
end
function AltaVoice_EditTalkTable(player, command)
local findloop = 1;
local find = AltaVoice_TalkTable[findloop];
local found = nil
while ((find) and (findloop <= AltaVoice_SpeakListLength))do
local find = AltaVoice_TalkTable[findloop];
if (find == player)then
found = findloop;
end
findloop = findloop +1;
end
if (command == "talk")then
if (AltaVoice_TalkTable[player])then
AltaVoice_TalkTable[player].talk = "talk";
else
AltaVoice_TalkTable[player] = {talk = "talk", name = player};
end
end
if (command == "silent")then
if (AltaVoice_TalkTable[player])then
AltaVoice_TalkTable[player].talk = "silent";
end
end
AltaVoice_UpdateTalkList();
end
function AltaVoice_UpdateTalkList()
local onTalkLoop = 1;
local listLoop = 1;
local noOneTalking = true;
for i,v in ipairs(AltaVoice_TalkTable) do
local getName = AltaVoice_TalkTable[i].name;
local talking = AltaVoice_TalkTable[i].talk;
if ((AltaVoice_SVars[AltaVoice_PlayerOfRealm].ListMode == "OnTalk") and (talking == "talk"))then
getglobal("AltaVoice_VoiceWindowTitle_UserSpeaking_"..onTalkLoop.."_Name"):SetText(getName);
getglobal("AltaVoice_VoiceWindowTitle_UserSpeaking_"..onTalkLoop):Show();
getglobal("AltaVoice_VoiceWindowTitle_UserSpeaking_"..onTalkLoop.."_SpeakTexture"):Show();
noOneTalking = false;
onTalkLoop = onTalkLoop + 1;
end
if (AltaVoice_SVars[AltaVoice_PlayerOfRealm].ListMode == "List")then
if (talking == "talk")then
getglobal("AltaVoice_VoiceWindowTitle_UserSpeaking_"..listLoop.."_Name"):SetText(getName);
getglobal("AltaVoice_VoiceWindowTitle_UserSpeaking_"..listLoop):Show();
getglobal("AltaVoice_VoiceWindowTitle_UserSpeaking_"..listLoop.."_SpeakTexture"):Show();
noOneTalking = false;
end
if (talking == "silent")then
getglobal("AltaVoice_VoiceWindowTitle_UserSpeaking_"..listLoop.."_Name"):SetText(getName);
getglobal("AltaVoice_VoiceWindowTitle_UserSpeaking_"..listLoop):Show();
getglobal("AltaVoice_VoiceWindowTitle_UserSpeaking_"..listLoop.."_SpeakTexture"):Hide();
end
listLoop = listLoop +1;
end
end
if (noOneTalking)then
AltaVoice_ResetVolume();
end
if (AltaVoice_SVars[AltaVoice_PlayerOfRealm].ListMode == "OnTalk")then
while (onTalkLoop <= AltaVoice_SVars[AltaVoice_PlayerOfRealm].SpeakListLength)do
getglobal("AltaVoice_VoiceWindowTitle_UserSpeaking_"..onTalkLoop):Hide();
onTalkLoop = onTalkLoop +1;
end
end
if (AltaVoice_SVars[AltaVoice_PlayerOfRealm].ListMode == "List")then
while (listLoop <= AltaVoice_SVars[AltaVoice_PlayerOfRealm].SpeakListLength)do
getglobal("AltaVoice_VoiceWindowTitle_UserSpeaking_"..listLoop):Hide();
listLoop = listLoop +1;
end
end
end
function AltaVoice_InvitePlayer()
local playerToInvite = AltaVoice_Menu_Panel_InvitePlayerFrame_PlayerToInvite:GetText();
if ((playerToInvite)and(AltaVoice_MasterChannelID))then
SendChatMessage("inv "..playerToInvite.." "..AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel, "CHANNEL", AltaVoice_Language, AltaVoice_MasterChannelID);
DEFAULT_CHAT_FRAME:AddMessage("AltaVoice : Inviting "..playerToInvite.." to join this channel.", 0.0, 1.0, 0.0);
end
end
function AltaVoice_InviteRequested(from, channel)
if (AltaVoice_SVars[AltaVoice_PlayerOfRealm].AllowInvites)then
if (channel == AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel)then
SendChatMessage("inr "..from.." AJ", "CHANNEL", AltaVoice_Language, AltaVoice_MasterChannelID);
else
AltaVoice_InviteRequestWindow_Text:SetText(from.." is inviting you to join "..channel);
AltaVoice_InviteRequestWindow:Show();
end
else
SendChatMessage("inr "..from.." NA", "CHANNEL", AltaVoice_Language, AltaVoice_MasterChannelID);
end
end
function AltaVoice_DipVolume()
if (AltaVoice_VolumeDipped == false)then
AltaVoice_Volume = {};
AltaVoice_Volume.Master = GetCVar("MasterVolume");
AltaVoice_Volume.Sound = GetCVar("SoundVolume");
AltaVoice_Volume.Music = GetCVar("MusicVolume");
AltaVoice_Volume.Ambience = GetCVar("AmbienceVolume");
SetCVar("MasterVolume", AltaVoice_SVars[AltaVoice_PlayerOfRealm].VolumeDipValues.Master);
SetCVar("SoundVolume", AltaVoice_SVars[AltaVoice_PlayerOfRealm].VolumeDipValues.Sound);
SetCVar("MusicVolume", AltaVoice_SVars[AltaVoice_PlayerOfRealm].VolumeDipValues.Music);
SetCVar("AmbienceVolume", AltaVoice_SVars[AltaVoice_PlayerOfRealm].VolumeDipValues.Ambience);
AltaVoice_VolumeDipped = true;
end
end
function AltaVoice_ResetVolume()
if (AltaVoice_VolumeDipped)then
SetCVar("MasterVolume", AltaVoice_Volume.Master);
SetCVar("SoundVolume", AltaVoice_Volume.Sound);
SetCVar("MusicVolume", AltaVoice_Volume.Music);
SetCVar("AmbienceVolume", AltaVoice_Volume.Ambience);
AltaVoice_VolumeDipped = false;
end
end
function AltaVoice_RefreshVisuals()
AltaVoice_VoiceWindowTitle:SetWidth(AltaVoice_SVars[AltaVoice_PlayerOfRealm].Appearance.TalkWindow.Width);
AltaVoice_VoiceWindowTitle:SetScale(AltaVoice_SVars[AltaVoice_PlayerOfRealm].Appearance.TalkWindow.Scale);
AltaVoice_VoiceWindowTitle:SetPoint("TOPLEFT", "AltaVoice_VoiceWindowTitleScaler", "TOPLEFT", 0 ,0);
end
The trouble is that when the addon is clicked on an error pops up pretainning to the AltaVoice_JoinChannel() function (line 94). That is linked to line 154 which also gives an error. "attempt to index field: ? (a nil value" thats the error i get. Also the sliders that are supposed to be on the window don't show up but that, i think, has to do with the XML file and not the Lua, but i may be wrong. Can any one help me out with this?
function AltaVoice_JoinVoiceChannel()
local player = UnitName("player");
local realm = GetRealmName();
AltaVoice_PlayerOfRealm = player.." of "..realm;
local _, isActive = JoinChannelByName(AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel);
if (isActive == nil)then
JoinChannelByName(AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel);
RemoveChatWindowChannel(DEFAULT_CHAT_FRAME:GetID(), AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel);
AltaVoice_ChannelName = GetChannelName(AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel);
end
AltaVoice_ChannelName = GetChannelName(AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel);
AltaVoice_JoinMasterChannel();
end
Thats the segment that is causing all the trouble and here is the whole thing for reference
BINDING_HEADER_ALTAVOICE = "AltaVoice";
BINDING_NAME_PUSHTOTALK = "Push To Talk";
-- Default Variables
AltaVoice_SVars = {};
AltaVoice_TalkTable = {};
AltaVoice_ActiveChannels = {};
AltaVoice_VolumeDipped = false;
function AltaVoice_OnLoad()
this:RegisterEvent("ADDON_LOADED");
arg1 = AltaVoice;
this:RegisterEvent("CHAT_MSG_CHANNEL");
UIErrorsFrame:AddMessage("AltaVoiceLoaded", 0, 1.0, 0, 1.0, UIERRORS_HOLD_TIME);
DEFAULT_CHAT_FRAME:AddMessage("AltaVoice : AltaVoice Loaded", 0.0, 1.0, 0.0);
AltaVoice_Language = this.language;
-- Register Slash Commands
SlashCmdList["AltaVoice"] = function(msg)
AltaVoice_SlashHandler(msg);
end
SLASH_AltaVoice1 = "/altavoice";
end
function AltaVoice_SlashHandler(msg)
if (msg == "")then
DEFAULT_CHAT_FRAME:AddMessage("AltaVoice : Slash Command List :", 0.0, 1.0, 0.0);
DEFAULT_CHAT_FRAME:AddMessage("AltaVoice : /altavoice show", 0.0, 1.0, 0.0);
DEFAULT_CHAT_FRAME:AddMessage("AltaVoice : /altavoice hide", 0.0, 1.0, 0.0);
end
if (msg == "show")then
AltaVoice_VoiceWindowTitle:Show();
end
if (msg == "hide")then
AltaVoice_VoiceWindowTitle:Hide();
AltaVoice_Menu_Title:Hide();
end
end
function AltaVoice_LoadProfile()
local player = UnitName("player");
local realm = GetCVar("realmName");
AltaVoice_PlayerOfRealm = player.." of "..realm;
if (AltaVoice_SVars[AltaVoice_PlayerOfRealm])then
AltaVoice_RefreshVisuals();
DEFAULT_CHAT_FRAME:AddMessage("AltaVoice : Loaded Profile for "..AltaVoice_PlayerOfRealm..".", 0.0, 1.0, 0.0);
else
AltaVoice_SVars[AltaVoice_PlayerOfRealm] = {};
if (IsInGuild())then
local guildName = GetGuildInfo("player");
local findSpaces = string.find(guildName, " ");
if (findSpaces)then
local starts, ends, cursor = 0,0,1;
local repairedName = "";
while (starts ~=nil)do
starts, ends = string.find(guildName, " ", cursor);
if (starts ~=nil)then
repairedName = repairedName..string.sub(guildName, cursor, starts-1);
cursor = ends +1;
else
repairedName = repairedName..string.sub(guildName, cursor);
end
end
guildName = repairedName;
end
AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel = "AltaVoice"..guildName;
else
AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel = "AltaVoice"..player;
end
AltaVoice_SVars[AltaVoice_PlayerOfRealm].SpeakListLength = 40;
AltaVoice_SVars[AltaVoice_PlayerOfRealm].ListMode = "List";
AltaVoice_SVars[AltaVoice_PlayerOfRealm].AllowInvites = true;
AltaVoice_SVars[AltaVoice_PlayerOfRealm].VolumeDip = false;
AltaVoice_SVars[AltaVoice_PlayerOfRealm].VolumeDipValues = {};
AltaVoice_SVars[AltaVoice_PlayerOfRealm].VolumeDipValues.Master = GetCVar("MasterVolume");
AltaVoice_SVars[AltaVoice_PlayerOfRealm].VolumeDipValues.Sound = GetCVar("SoundVolume");
AltaVoice_SVars[AltaVoice_PlayerOfRealm].VolumeDipValues.Music = GetCVar("MusicVolume");
AltaVoice_SVars[AltaVoice_PlayerOfRealm].VolumeDipValues.Ambience = GetCVar("AmbienceVolume");
AltaVoice_SVars[AltaVoice_PlayerOfRealm].Appearance = {};
AltaVoice_SVars[AltaVoice_PlayerOfRealm].Appearance.TalkWindow = {};
AltaVoice_SVars[AltaVoice_PlayerOfRealm].Appearance.TalkWindow.Width = 100;
AltaVoice_SVars[AltaVoice_PlayerOfRealm].Appearance.TalkWindow.Scale = 1;
DEFAULT_CHAT_FRAME:AddMessage("AltaVoice : Profile Created for "..AltaVoice_PlayerOfRealm..".", 0.0, 1.0, 0.0);
end
end
function AltaVoice_JoinVoiceChannel()
local player = UnitName("player");
local realm = GetRealmName();
AltaVoice_PlayerOfRealm = player.." of "..realm;
local _, isActive = JoinChannelByName(AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel);
if (isActive == nil)then
JoinChannelByName(AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel);
RemoveChatWindowChannel(DEFAULT_CHAT_FRAME:GetID(), AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel);
AltaVoice_ChannelName = GetChannelName(AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel);
end
AltaVoice_ChannelName = GetChannelName(AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel);
AltaVoice_JoinMasterChannel();
end
function AltaVoice_JoinVoiceChannelOnClick()
local channelName = "AltaVoice"..AltaVoice_Menu_Panel_ChannelName:GetText();
local findSpaces = string.find(channelName, " ");
if (findSpaces)then
local starts, ends, cursor = 0,0,1;
local repairedName = "";
while (starts ~=nil)do
starts, ends = string.find(channelName, " ", cursor);
if (starts ~=nil)then
repairedName = repairedName..string.sub(channelName, cursor, starts-1);
cursor = ends +1;
else
repairedName = repairedName..string.sub(channelName, cursor);
end
end
channelName = repairedName;
AltaVoice_Menu_Panel_ChannelName:SetText(repairedName);
end
AltaVoice_Menu_Panel_ChannelName:ClearFocus();
ChatFrame1.editBox:SetText("/leave "..AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel);
ChatEdit_SendText(ChatFrame1.editBox);
AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel = channelName;
AltaVoice_JoinVoiceChannel();
AltaVoice_TalkTable = {};
AltaVoice_UpdateTalkList();
end
function AltaVoice_JoinMasterChannel()
local _, isActive = JoinChannelByName("AltaVoiceMaster");
if (isActive == nil)then
JoinChannelByName("AltaVoiceMaster");
RemoveChatWindowChannel(DEFAULT_CHAT_FRAME:GetID(), "AltaVoiceMaster");
end
AltaVoice_MasterChannelID = GetChannelName("AltaVoiceMaster");
end
function AltaVoice_StartTalk()
if (AltaVoice_ChannelName == nil)then
AltaVoice_JoinVoiceChannel();
end
SendChatMessage("StartTalk", "CHANNEL", AltaVoice_Language, AltaVoice_ChannelName);
end
function AltaVoice_StopTalk()
SendChatMessage("StopTalk", "CHANNEL", AltaVoice_Language, AltaVoice_ChannelName);
end
function AltaVoice_OnEvent()
if (event == "CHAT_MSG_CHANNEL") then
if (AltaVoice_ChannelName == nil)then
AltaVoice_JoinVoiceChannel();
end
local player = arg2;
local fromChannel = arg4;
local monitorChannel = AltaVoice_ChannelName..". "..AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel;
local masterChannel = AltaVoice_MasterChannelID..". AltaVoiceMaster";
if (fromChannel == monitorChannel)then
if (arg1 == "StartTalk")then
AltaVoice_EditTalkTable(player, "talk");
if (AltaVoice_SVars[AltaVoice_PlayerOfRealm].VolumeDip)then
AltaVoice_DipVolume();
end
end
if (arg1 == "StopTalk")then
AltaVoice_EditTalkTable(player, "silent");
end
end
if (fromChannel == masterChannel)then
local msg = arg1;
local command = string.sub(msg,1,3);
local starts, ends = string.find(msg, " ", 5);
local property1 = string.sub(msg, 5, starts-1);
local property2 = string.sub(msg, ends+1);
-- recieve invite request
if ((command == "inv") and (property1 == UnitName("player")))then
AltaVoice_InviteRequestFrom = player;
AltaVoice_InviteRequestChannel = property2;
AltaVoice_InviteRequested(player, property2);
end
-- recieve invite response - Not Accepting
if ((command == "inr") and (property1 == UnitName("player")) and (property2 == "NA"))then
DEFAULT_CHAT_FRAME:AddMessage("AltaVoice : "..player.." is not accepting invites at this time.", 1.0, 0.0, 0.0);
end
-- recieve invite response - Declined
if ((command == "inr") and (property1 == UnitName("player")) and (property2 == "DE"))then
DEFAULT_CHAT_FRAME:AddMessage("AltaVoice : "..player.." declined your invitation.", 1.0, 0.0, 0.0);
end
-- recieve invite response - Already Joined
if ((command == "inr") and (property1 == UnitName("player")) and (property2 == "AJ"))then
DEFAULT_CHAT_FRAME:AddMessage("AltaVoice : "..player.." is already joined to this channel.", 1.0, 0.0, 0.0);
end
-- recieve invite response - Accepted
if ((command == "inr") and (property1 == UnitName("player")) and (property2 == "AC"))then
DEFAULT_CHAT_FRAME:AddMessage("AltaVoice : "..player.." accepted your invitation.", 0.0, 1.0, 0.0);
end
end
end
if (event == "VARIABLES_LOADED")then
AltaVoice_LoadProfile();
end
end
function AltaVoice_EditTalkTable(player, command)
local findloop = 1;
local find = AltaVoice_TalkTable[findloop];
local found = nil
while ((find) and (findloop <= AltaVoice_SpeakListLength))do
local find = AltaVoice_TalkTable[findloop];
if (find == player)then
found = findloop;
end
findloop = findloop +1;
end
if (command == "talk")then
if (AltaVoice_TalkTable[player])then
AltaVoice_TalkTable[player].talk = "talk";
else
AltaVoice_TalkTable[player] = {talk = "talk", name = player};
end
end
if (command == "silent")then
if (AltaVoice_TalkTable[player])then
AltaVoice_TalkTable[player].talk = "silent";
end
end
AltaVoice_UpdateTalkList();
end
function AltaVoice_UpdateTalkList()
local onTalkLoop = 1;
local listLoop = 1;
local noOneTalking = true;
for i,v in ipairs(AltaVoice_TalkTable) do
local getName = AltaVoice_TalkTable[i].name;
local talking = AltaVoice_TalkTable[i].talk;
if ((AltaVoice_SVars[AltaVoice_PlayerOfRealm].ListMode == "OnTalk") and (talking == "talk"))then
getglobal("AltaVoice_VoiceWindowTitle_UserSpeaking_"..onTalkLoop.."_Name"):SetText(getName);
getglobal("AltaVoice_VoiceWindowTitle_UserSpeaking_"..onTalkLoop):Show();
getglobal("AltaVoice_VoiceWindowTitle_UserSpeaking_"..onTalkLoop.."_SpeakTexture"):Show();
noOneTalking = false;
onTalkLoop = onTalkLoop + 1;
end
if (AltaVoice_SVars[AltaVoice_PlayerOfRealm].ListMode == "List")then
if (talking == "talk")then
getglobal("AltaVoice_VoiceWindowTitle_UserSpeaking_"..listLoop.."_Name"):SetText(getName);
getglobal("AltaVoice_VoiceWindowTitle_UserSpeaking_"..listLoop):Show();
getglobal("AltaVoice_VoiceWindowTitle_UserSpeaking_"..listLoop.."_SpeakTexture"):Show();
noOneTalking = false;
end
if (talking == "silent")then
getglobal("AltaVoice_VoiceWindowTitle_UserSpeaking_"..listLoop.."_Name"):SetText(getName);
getglobal("AltaVoice_VoiceWindowTitle_UserSpeaking_"..listLoop):Show();
getglobal("AltaVoice_VoiceWindowTitle_UserSpeaking_"..listLoop.."_SpeakTexture"):Hide();
end
listLoop = listLoop +1;
end
end
if (noOneTalking)then
AltaVoice_ResetVolume();
end
if (AltaVoice_SVars[AltaVoice_PlayerOfRealm].ListMode == "OnTalk")then
while (onTalkLoop <= AltaVoice_SVars[AltaVoice_PlayerOfRealm].SpeakListLength)do
getglobal("AltaVoice_VoiceWindowTitle_UserSpeaking_"..onTalkLoop):Hide();
onTalkLoop = onTalkLoop +1;
end
end
if (AltaVoice_SVars[AltaVoice_PlayerOfRealm].ListMode == "List")then
while (listLoop <= AltaVoice_SVars[AltaVoice_PlayerOfRealm].SpeakListLength)do
getglobal("AltaVoice_VoiceWindowTitle_UserSpeaking_"..listLoop):Hide();
listLoop = listLoop +1;
end
end
end
function AltaVoice_InvitePlayer()
local playerToInvite = AltaVoice_Menu_Panel_InvitePlayerFrame_PlayerToInvite:GetText();
if ((playerToInvite)and(AltaVoice_MasterChannelID))then
SendChatMessage("inv "..playerToInvite.." "..AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel, "CHANNEL", AltaVoice_Language, AltaVoice_MasterChannelID);
DEFAULT_CHAT_FRAME:AddMessage("AltaVoice : Inviting "..playerToInvite.." to join this channel.", 0.0, 1.0, 0.0);
end
end
function AltaVoice_InviteRequested(from, channel)
if (AltaVoice_SVars[AltaVoice_PlayerOfRealm].AllowInvites)then
if (channel == AltaVoice_SVars[AltaVoice_PlayerOfRealm].Monitor_Channel)then
SendChatMessage("inr "..from.." AJ", "CHANNEL", AltaVoice_Language, AltaVoice_MasterChannelID);
else
AltaVoice_InviteRequestWindow_Text:SetText(from.." is inviting you to join "..channel);
AltaVoice_InviteRequestWindow:Show();
end
else
SendChatMessage("inr "..from.." NA", "CHANNEL", AltaVoice_Language, AltaVoice_MasterChannelID);
end
end
function AltaVoice_DipVolume()
if (AltaVoice_VolumeDipped == false)then
AltaVoice_Volume = {};
AltaVoice_Volume.Master = GetCVar("MasterVolume");
AltaVoice_Volume.Sound = GetCVar("SoundVolume");
AltaVoice_Volume.Music = GetCVar("MusicVolume");
AltaVoice_Volume.Ambience = GetCVar("AmbienceVolume");
SetCVar("MasterVolume", AltaVoice_SVars[AltaVoice_PlayerOfRealm].VolumeDipValues.Master);
SetCVar("SoundVolume", AltaVoice_SVars[AltaVoice_PlayerOfRealm].VolumeDipValues.Sound);
SetCVar("MusicVolume", AltaVoice_SVars[AltaVoice_PlayerOfRealm].VolumeDipValues.Music);
SetCVar("AmbienceVolume", AltaVoice_SVars[AltaVoice_PlayerOfRealm].VolumeDipValues.Ambience);
AltaVoice_VolumeDipped = true;
end
end
function AltaVoice_ResetVolume()
if (AltaVoice_VolumeDipped)then
SetCVar("MasterVolume", AltaVoice_Volume.Master);
SetCVar("SoundVolume", AltaVoice_Volume.Sound);
SetCVar("MusicVolume", AltaVoice_Volume.Music);
SetCVar("AmbienceVolume", AltaVoice_Volume.Ambience);
AltaVoice_VolumeDipped = false;
end
end
function AltaVoice_RefreshVisuals()
AltaVoice_VoiceWindowTitle:SetWidth(AltaVoice_SVars[AltaVoice_PlayerOfRealm].Appearance.TalkWindow.Width);
AltaVoice_VoiceWindowTitle:SetScale(AltaVoice_SVars[AltaVoice_PlayerOfRealm].Appearance.TalkWindow.Scale);
AltaVoice_VoiceWindowTitle:SetPoint("TOPLEFT", "AltaVoice_VoiceWindowTitleScaler", "TOPLEFT", 0 ,0);
end
The trouble is that when the addon is clicked on an error pops up pretainning to the AltaVoice_JoinChannel() function (line 94). That is linked to line 154 which also gives an error. "attempt to index field: ? (a nil value" thats the error i get. Also the sliders that are supposed to be on the window don't show up but that, i think, has to do with the XML file and not the Lua, but i may be wrong. Can any one help me out with this?