Thread Tools Display Modes
08-15-15, 03:33 PM   #1
rivriv0
A Defias Bandit
Join Date: Aug 2015
Posts: 2
TriviaAnswers

http://wow.curseforge.com/addons/triviaanswers/ so i want to make it so that i can set it on custom channel but when i try to use it for custom channel it has an error can u help me


channel is channel number 5 /global


here's the bug log

Date: 2015-08-15 14:40:15
ID: 1
Error occured in: Global
Count: 1
Message: SendChatMessage(): Channel send missing channel number
Debug:
[C]: ?
[C]: SendChatMessage()
TriviaAnswers\TriviaAnswers.lua:302: AnnounceAnswer()
TriviaAnswers\TriviaAnswers.lua:244: OnUpdate()
TriviaAnswers\TriviaAnswers.lua:224:
TriviaAnswers\TriviaAnswers.lua:224
Locals:
(*temporary) = "blackrpck spire"
(*temporary) = "channel"
(*temporary) = nil
(*temporary) = nil

AddOns:
Swatter, v5.19.5445 (QuiescentQuoll)
AucAdvanced, v5.19.5445 (QuiescentQuoll)
AucFilterBasic, v5.19.5445 (QuiescentQuoll)
AucFilterOutlier, v5.19.5445.5437(5.19/embedded)
AucMatchUndercut, v5.19.5445.5364(5.19/embedded)
AucStatHistogram, v5.19.5445 (QuiescentQuoll)
AucStatiLevel, v5.19.5445 (QuiescentQuoll)
AucStatPurchased, v5.19.5445 (QuiescentQuoll)
AucStatSales, v5.19.5445.5376(5.19/embedded)
AucStatSimple, v5.19.5445 (QuiescentQuoll)
AucStatStdDev, v5.19.5445 (QuiescentQuoll)
AucStatWOWEcon, v5.19.5445.5323(5.19/embedded)
AucUtilAHWindowControl, v5.19.5445.5347(5.19/embedded)
AucUtilAppraiser, v5.19.5445.5438(5.19/embedded)
AucUtilAskPrice, v5.19.5445.5347(5.19/embedded)
AucUtilAutoMagic, v5.19.5445.5443(5.19/embedded)
AucUtilCompactUI, v5.19.5445.5444(5.19/embedded)
AucUtilEasyBuyout, v5.19.5445.5427(5.19/embedded)
AucUtilFixAH, v5.19.5445 (QuiescentQuoll)
AucUtilItemSuggest, v5.19.5445.5417(5.19/embedded)
AucUtilPriceLevel, v5.19.5445.5444(5.19/embedded)
AucUtilScanButton, v5.19.5445.5403(5.19/embedded)
AucUtilScanFinish, v5.19.5445.5347(5.19/embedded)
AucUtilScanProgress, v5.19.5445.4979(5.19/embedded)
AucUtilScanStart, v5.19.5445.5347(5.19/embedded)
AucUtilSearchUI, v5.19.5445.5373(5.19/embedded)
AucUtilSimpleAuction, v5.19.5445.5415(5.19/embedded)
AucUtilVendMarkup, v5.19.5445.4828(5.19/embedded)
Babylonian, v5.1.DEV.332(/embedded)
BeanCounter, v5.19.5445 (QuiescentQuoll)
Configator, v5.1.DEV.359(/embedded)
DebugLib, v5.1.DEV.337(/embedded)
Enchantrix, v5.19.5445 (QuiescentQuoll)
EnchantrixBarker, v5.19.5445 (QuiescentQuoll)
Informant, v5.19.5445 (QuiescentQuoll)
LibExtraTip, v5.12.DEV.355(/embedded)
SlideBar, v5.19.5445 (QuiescentQuoll)
Stubby, v5.19.5445 (QuiescentQuoll)
TipHelper, v5.12.DEV.351(/embedded)
TriviaAnswers, v1.01
TriviaBot, v2.8.8
TriviaBotQuestionsWoW1, v
TriviaBotQuestionsWoW2, v
ZygorGuidesViewer, v4.0
BlizRuntimeLib_enUS v5.4.2.50400 <logon.warmane.com>
(ck=7d6)

Last edited by rivriv0 : 08-15-15 at 03:39 PM.
  Reply With Quote
08-15-15, 07:30 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
What is your code? Global isn't always channel 5. For most people, it's probably channel 1, actually. Did you follow the tip shown here? http://wow.gamepedia.com/API_SendChatMessage
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
08-16-15, 09:05 AM   #3
rivriv0
A Defias Bandit
Join Date: Aug 2015
Posts: 2
I found something like that in the trivianswers.lua but it's nothing like the one in the pedia


SendChatMessage(answer,struct[3],nil,struct[4])




also if you want the lua i have it here
TriviaAnswers = LibStub("AceAddon-3.0"):NewAddon("TriviaAnswers","AceConsole-3.0", "AceEvent-3.0");

local options = {
type = 'group',
args = {
main = {
type = 'group',
childGroups = 'tab',
order = 1,
args = {
label = {
name = " Version " .. GetAddOnMetadata("TriviaAnswers","version"),
type = "description",
order = 1,
},
params = {
type = 'group',
name = 'Global Settings',
inline = true,
order = 10,
args = {
lowercase = {
name = 'Lower Case',
desc = 'Lower case answers',
handler = TriviaAnswers, -- should become self
get = "GetConfigValue",
set = "SetConfigValue",
type = 'toggle',
},
mintime = {
order = 20,
name = 'Min Time',
desc = 'Minimum time before answer',
type = 'range',
min = 0,
max = 10,
step = 0.5,
handler = TriviaAnswers, -- should become self
get = "GetConfigValue",
set = "SetConfigValue",
},
maxtime = {
order = 30,
name = 'Max Time',
desc = 'Maximum time before answer',
type = 'range',
min = 0,
max = 10,
step = 0.5,
handler = TriviaAnswers, -- should become self
get = "GetConfigValue",
set = "SetConfigValue",
},
errorrate = {
order = 20,
name = 'Error rate',
desc = 'Percent of time to make a typo',
type = 'range',
min = 0,
max = 1,
step = .01,
handler = TriviaAnswers, -- should become self
get = "GetConfigValue",
set = "SetConfigValue",
},
requeuetime = {
order = 50,
name = 'Requeue Time',
desc = 'Time to submit a "fixed" answer',
type = 'range',
min = 0,
max = 5,
step = 0.1,
handler = TriviaAnswers,
get = "GetConfigValue",
set = "SetConfigValue",
},
channel = {
name = 'Channel',
desc = 'Channel to answer on',
type = 'select',
values = {say='say',yell='yell',whisper='whisper',party='party',raid='raid',global='global',guild='guild',officer='officer'},
handler = TriviaAnswers, -- should become self
get = "GetConfigValue",
set = "SetConfigValue",
},
},
},
},
},
},
}

local DEFAULTS = {
params = {
mintime = 1,
maxtime = 2,
channel = 'say',
errorrate = 0,
requeuetime = 0.5,
lowercase = false,
},
}
local chat_types = {
['whisper'] = {"CHAT_MSG_WHISPER"},
['party'] = {"CHAT_MSG_PARTY","CHAT_MSG_PARTY_LEADER"},
['raid'] = {"CHAT_MSG_RAID","CHAT_MSG_RAID_LEADER"},
['guild'] = {"CHAT_MSG_GUILD"},
['officer'] = {"CHAT_MSG_OFFICER"},
['global'] = {"CHAT_MSG_GLOBAL"},
['say'] = {"CHAT_MSG_SAY"},
['yell'] = {"CHAT_MSG_YELL"},
}
local TriviaBot_QuestionPacks = {}
local TriviaBot_Questions = {}

function TriviaAnswers:GetVersion()
local ver = GetAddOnMetadata("TriviaAnswers","version");
if (ver) then return "v" .. ver; else return ""; end;
end

function TriviaAnswers:OnInitialize()
self.defaults = {
profile = {
TriviaAnswers = { },
}
}
self.db = LibStub("AceDB-3.0"):New("TriviaAnswersData", self.defaults,"global");
options.args.profile = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db)
LibStub("AceConfig-3.0"):RegisterOptionsTable("TriviaAnswers", options.args.main)
LibStub("AceConfigRegistry-3.0"):RegisterOptionsTable("TriviaAnswers Profile",options.args.profile)
self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("TriviaAnswers","TriviaAnswers")
self.profileFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("TriviaAnswers Profile","Profile","TriviaAnswers")
self.db.RegisterCallback(self, 'OnNewProfile', 'OnProfileReset')
self.db.RegisterCallback(self, 'OnProfileChanged', 'OnProfileReset')
self.db.RegisterCallback(self, 'OnProfileCopied', 'OnProfileReset')
self.db.RegisterCallback(self, 'OnProfileReset', 'OnProfileReset')
self.db.RegisterCallback(self, 'OnProfileDeleted', 'OnProfileReset')

self:RegisterChatCommand("TriviaAnswers","ChatCommand")
self:RegisterChatCommand("ta","ChatCommand")
local ver = self:GetVersion()
if (ver) then
self:Print("TriviaAnswers " .. ver .. " Initialized")
else
self:Print("TriviaAnswers Initialized")
end
end

function TriviaAnswers:GetValue(frame,name,noProfile)
if (not self.db.profile.TriviaAnswers) then self.db.profile.TriviaAnswers = {}; end;
if (frame) then
if ((not noProfile) and self.db.profile.TriviaAnswers[frame] and self.db.profile.TriviaAnswers[frame][name] ~= nil) then
return self.db.profile.TriviaAnswers[frame][name]
end
return DEFAULTS[frame][name]
end
return nil
end
function TriviaAnswers:SetValue(frame,name,value)
if (not self.db.profile.TriviaAnswers) then self.db.profile.TriviaAnswers = {}; end;
if (frame) then
if (not self.db.profile.TriviaAnswers[frame]) then self.db.profile.TriviaAnswers[frame] = {}; end
self.db.profile.TriviaAnswers[frame][name] = value;
end
return value
end

function TriviaAnswers:GetConfigValue(info)
-- this is so broken - I need a string, not a number
local frame = info[#info-1]
local name = info[#info]
local tmp = self:GetValue(frame,name)
if (info.type=='input') then
return tostring(tmp)
else
return tmp;
end
end
function TriviaAnswers:SetConfigValue(info,value)
local frame = info[#info-1]
local name = info[#info]
-- special checks
if (name == "channel") then
self:UnListen(self:GetValue("params","channel"))
end
self:SetValue(frame,name,value)
if (name == "channel") then
self:Listen(value)
end
end

function TriviaAnswers:OnProfileReset()
self:LoadProfile()
end

function TriviaAnswers:ApplySettings()
self:LoadProfile()
end

function TriviaAnswers:ChatCommand(input)
if (not input or input:trim()=="") then
InterfaceOptionsFrame_OpenToCategory(self.optionsFrame)
return
end
input=input:trim()
self:Print("Valid Commands")
self:Print("<blank>: Open the config pane")
end

function TriviaAnswers:Reset()
self.data = {}
end

function TriviaAnswers:LoadProfile()
self:Reset();
self:Listen(self:GetValue("params","channel"))
self:FindPacks()
end

function TriviaAnswers:OnEnable()
if (not self.frame) then
self.frame = CreateFrame("Frame")
self.frame:SetScript("OnUpdate",function() self:OnUpdate(); end)
end
self:LoadProfile()
self.frame:Show()
end

function TriviaAnswers:OnDisable()
if (self.frame) then self.frame:Hide(); end
self:Reset()
-- i really need to do more here
end

function TriviaAnswers:OnUpdate()
if (not self.data or not self.data.answers) then return; end
for i=1,#self.data.answers do
-- going to do a stupid recursive version because i'm lazy
if (self.data.answers[i][1] < GetTime()) then
local struct = self.data.answers[i]
table.remove(self.data.answers,i)
-- remove first in case announcenswer goes splat
self:AnnounceAnswer(struct)
self:OnUpdate()
return
end
end
end

function TriviaAnswers:Listen(channel)
if (not channel) then return; end
local events = chat_types[channel]
if (not events) then
self:Print("Unknown type " .. channel .. ". Not listening")
return
end
for _,e in pairs(events) do
self:RegisterEvent(e,"ChatIn")
end
end

function TriviaAnswers:UnListen(channel)
if (not channel) then return; end
local events = chat_types[channel]
if (not events) then
self:Print("Unknown type " .. channel .. ". Not unlistening")
return
end
for _,e in pairs(events) do
self:UnregisterEvent(e,"ChatIn")
end
end

function TriviaAnswers:ComputeDelay()
local mintime = tonumber(self:GetValue("params","mintime"))
local maxtime = tonumber(self:GetValue("params","maxtime"))
if (maxtime < mintime) then maxtime = mintime; end
local range = maxtime - mintime;
return mintime + random()* range;
end

function TriviaAnswers:MungeResponse(struct)
local answer = struct[2]
if (self:GetValue("params","lowercase")) then
answer = string.lower(answer)
end
if (random() < self:GetValue("params","errorrate")) then
-- requeue to do correction
struct[1] = struct[1] + self:GetValue("params","requeuetime")
tinsert(self.data.answers,struct)
-- single transposition for now
local pos = random(answer:len())
answer = answer:sub(1,pos-1) .. string.char(string.byte(answer:sub(pos,pos))+1) .. answer:sub(pos+1)
end
return answer
end

function TriviaAnswers:AnnounceAnswer(struct)
if (not struct) then return; end
local answer = self:MungeResponse(struct)
SendChatMessage(answer,struct[3],nil,struct[4])
end

function TriviaAnswers:QueueResponse(answer)
if (not self.data) then self.data = {}; end
if (not self.data.answers) then self.data.answers = {}; end
local delay = self:ComputeDelay()
local struct = {delay + GetTime(), answer,self:GetValue("params","channel")}
if (delay > 0) then
tinsert(self.data.answers,struct)
else
self:AnnounceAnswer(struct)
end
end

function TriviaAnswers:ChatIn(event,msg)
local question = string.match(msg,"%[TriviaBot%]: Q?:? ?(.*)");
if (not question) then
question = string.match(msg,"%[TB%]: Q?:? ?(.*)");
end
if (not question) then -- didn't match expected patterns. not a question
return
end
for _,c in pairs(TriviaBot_Questions) do
if (c) then
for j,q in pairs(c.Question) do
if (q==question) then
self:QueueResponse(c.Answers[j][1])
return
end
end
end
end
end

function TriviaAnswers:FindPacks()
for i = 1, GetNumAddOns() do
local questionPack, _, _, enabled = GetAddOnInfo(i)
if enabled and not IsAddOnLoaded(i) and IsAddOnLoadOnDemand(i) then
local valid = GetAddOnMetadata(i, "X-TriviaBot-Questions")
if valid then
TriviaBot_QuestionPacks[#TriviaBot_QuestionPacks+1] = questionPack
local loaded, reason = LoadAddOn(questionPack)
if (loaded) then
self:Print(questionPack)
TriviaBot_Questions[i] = _G[questionPack]["QuestionList"]
else
self:Print("Not loaded")
end

end
end
end
end

Last edited by rivriv0 : 08-16-15 at 09:43 AM.
  Reply With Quote
08-21-15, 09:17 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Use [code] tags instead of [quote] tags around code to preserve indentation. [quote]d code is basically unreadable.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » TriviaAnswers


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off