Quantcast
WoWInterface - View Single Post - Just trying to revive an old add... need a little help
View Single Post
04-11-20, 12:34 AM   #1
TransformedBG
A Fallenroot Satyr
Join Date: Oct 2010
Posts: 21
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
Code:
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"] = {
"SAY",
"GUILD",
"PARTY",
"RAID",
"BATTLEGROUND",
}

--[[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 --
	self:RegisterEvent("PLAYER_LEVEL_UP");
	self:RegisterEvent("GUILD_ROSTER_UPDATE");
	self:RegisterEvent("CHAT_MSG_GUILD");
	GLUA_LoadMessage();
	--lvl = Level_Up()
end

function GLUA_LoadMessage()
	DEFAULT_CHAT_FRAME:AddMessage("Guild Level Up Announcer has been initialized!")
	DEFAULT_CHAT_FRAME:AddMessage(" Ver. 1.13.14");
end

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

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

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

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

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
		end
	end
end
simple xml
Code:
<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">
		<Scripts>
			<OnLoad>GLUA_OnLoad(self)</OnLoad>
			<OnEvent>GLUA_OnEvent(self, event, ...)</OnEvent>
		</Scripts>
	</Frame>
</UI>
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-1.0.1.1.lua:70: in function `GLUA_Message'
GLUA\GLUA-1.0.1.1.lua:115: in function `GLUA_OnEvent'
[string "*:OnEvent"]:1: in function <[string "*:OnEvent"]:1>
  Reply With Quote