Just trying to revive an old add... need a little help - WoWInterface
Thread Tools Display Modes
Prev Previous Post   Next Post Next
04-11-20, 12:34 AM   #1
A Fallenroot Satyr
Join Date: Oct 2010
Posts: 20
Just trying to revive an old add... need a little help

Not sure what all has changed, but i was trying to revive my old level announcer addon, and i haven't really touched it since probably BC... anyways... For the most part most of my functions work... I just dont know why i cant access global variables any more.. havent kept up with that.

simple lua file
local me = UnitName("player") -- Gets players Name
local lvl = UnitLevel("player")+1 --Gets Current Player Level (used to have an addon that +1 to this but i cant add to this level gets a global nil)
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(self)-- Loads on player login --
	--lvl = Level_Up()

function GLUA_LoadMessage()
	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

function GLUA_OnEvent(self, event, ...)
	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
simple xml
<UI xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/">
	<Script file="GLUA.lua" />

	<Frame name="GLUAFrame" hidden="false">
			<OnEvent>GLUA_OnEvent(self, event, ...)</OnEvent>
I had a bunch of this's all over, and figured out how to get rid of them.. but i feel like from looking around i need to do something like put my add on in a container or something. Im just trying to remember all this. like i said its been a while.

if i run the functions in wow doing /run GLUA_XXX most of them work. Only thing is OnEvent when its actually called by game (I simply call it /Run GLUA_OnEvent("player","PLAYER_LEVEL_UP); it doesnt error) where when its auto called im getting:
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 `GLUA_OnEvent'
[string "*:OnEvent"]:1: in function <[string "*:OnEvent"]:1>
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Just trying to revive an old add... need a little help

Thread Tools
Display Modes

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