WoWInterface - View Single Post - Just trying to revive an old add... need a little help
View Single Post
04-11-20, 11:21 PM   #5
A Fallenroot Satyr
Join Date: Oct 2010
Posts: 20
So i still have to be doing something wrong... when i call EventWatcher (/run EventWatcher("PLAYER_LEVEL_UP") i get the message as i am supposed to. I can see the addon loaded, etc.

--[[ Localise the Addon Wide Data Table ]]--
local addonName, addonData = ...

--[[ Localise any Addon Wide Sub Tables that are frequently accessed ]]--
local Translate = addonData.Translate

GLUA = {}
GLUA.GLUA_Frame = CreateFrame("Frame")

GLUA.GLUA_Frame:SetScript("OnEvent", function(self,event,...)--EventWatcher)

local me = UnitName("player") -- Gets players Name
local lvl = UnitLevel("player")+1 --Gets Current Player Level 
local race = UnitClass("player") --local varable to record what race you are.
local realm = GetRealmName(); -- Gets Realm name

--[[List to define chat channels]]--
channel_list = {}
channel_list["chan"] = {

--[[List to define different randomized quotes]]--
quote_this = {}
quote_this["level"] = {
"This has been a test of the Emergancy Ding System! "..me.."is now " ..lvl..".",
"My ding a ling. My ding a ling... looks like im level "..lvl.."!!!",
"DING, DING, DING... Looks like "..me.."just hit "..lvl.."!",
"Check this guys! Im now a level "..lvl.." "..race.."!",
"If you heard it once, you have heard it "..lvl.." times. DING!",
"Go ahead and just say grats alread! Cause i just hit level "..lvl.."!",
"Warning, Warnning,"..me.." You Just Hit Level "..lvl.."!",
"My microwave Dings and so do I! "..lvl.. " levels done!",
"Whats the difference between a rogue and a noob, they both pick locks! DING! That makes "..lvl.."!",
"This aint no AutoDing, okay well maybe a little... DING! now im level "..lvl.."!",
"Mama says every time a player Dings an angel gets its wings. DING level"..lvl.."!",
"Oh what is that noise? Sounds like someone just Dinged! Could it be "..me.."?! Woo hoo im level "..lvl.."!",

function GLUA_OnLoad()-- Loads on player login --
	DEFAULT_CHAT_FRAME:AddMessage("Guild Level Up Announcer has been initialized!")
	DEFAULT_CHAT_FRAME:AddMessage(" Ver. 1.13.14");

function GLUA_Message(quotes, channel)
	SendChatMessage(quotes, channel, nil, nil); --sends the chat message, party is just a filler for now testing

function GLUA_Channel()
	local num = 1 --you are Solo
		if UnitInParty("player")  then
			num = 3 -- your in a party
		if UnitInRaid("player") then
			num = 4 --Your in a raid group
		if UnitInBattleground("player") then
			num = 5 --You are Battleground
	return num

function GLUA_Quotes()
	local list = quote_this["level"]
	local quote = list[math.random(table.getn(list))]
	return quote

function GLUA_GUILD_CHECK(test)
	test = GetGuildInfo("player")
		if (test == nil)then
			test = false 
			return test
   test = true
   return test

--[[ Monitor registered events ]]--
function EventWatcher(event,...)
	-- Store the arguments into an array to access when needed
    local args = { ... }
	if event == "PLAYER_ENTERING_WORLD" then
       -- Deal with player entering world
	   print("Someone did something in the world")
    if event == "ADDON_LOADED" then
      -- Deal with any addons being loaded that you want to watch for ( args[1] is addon being loaded )
	  print("GLUA Addon Loaded")
	if event == "PLAYER_LEVEL_UP" then --if a player levels up do the following
		print("Player Leveled Up = " .. event)
		local quote_to_share = GLUA_Quotes()
		local chanX = channel_list["chan"]
		local chan_number= GLUA_Channel()
			GLUA_Message(quote_to_share, chanX[chan_number]) -- send message to party or raid
		local check_guild = GLUA_GUILD_CHECK(check_guild)
		--[[if (check_guild == true) then
			print("not in a guild")
			GLUA_Message(quote_to_share, chanX[2]) -- return a second message to guild
1x [ADDON_ACTION_BLOCKED] AddOn 'GLUA' tried to call the protected function 'UNKNOWN()'.
!BugGrabber\BugGrabber.lua:519: in function <!BugGrabber\BugGrabber.lua:519>
[C]: ?
[C]: in function `SendChatMessage'
GLUA\GLUA- in function `GLUA_Message'
GLUA\GLUA- in function `EventWatcher'
GLUA\GLUA- in function <GLUA\GLUA.lua:29>

I noticed your template had the function as a local function.... is that needed? if i leave it like that i get the nil value error...

My problem seems to be when i call my GLUA_Message function, which calls to my table and randomly picks a quote, then says to send that message to self, party, bg, raid, and guild if in one. im getting the protected function unknown.... So from looking at your link it spears SendChatMessage is a protected function now...

Because i can get it to print "Player Leveled up = PLAYER_LEVEL_UP. meaning i get to line 121 of my code . I can add print("calling SendChatMessage with "..quote_to_share.." on channel number "..chan_number.."!") to line 126 unter ocal chan_number=GLUA_Channel() and see that its call the quote and level properly, just cant send the chat message. and by adding print(quotes) and print(channel) i can see that it passes the correct values to it..

The only thing i can think is that Locals:InCombatSkipped in the error, may not be letting me pass it to a secure function.. i guess i would need to check out of combat?
  Reply With Quote