Thread Tools Display Modes
Prev Previous Post   Next Post Next
06/16/17, 07:26 AM   #1
Devisaur
AddOn Author - Click to view addons
Join Date: Jun 2017
Posts: 6
Variable Initalization Issue

************
Solved - XML Control had the same name as the addon
***********


I'm fairly new to Lua so perhaps I'm missing something obvious. My IF statement that is checking the addon name keeps failing -- after doing some digging I've found that my TimetoLevel.name is never being set.

Is there a reason that these variables would fail set?

Code:
TimetoLevel = {}
TimetoLevel.name = "TimetoLevel"

function TimetoLevel.Initalize(eventCode, addOnName)
	--TimetoLevelCounter:SetText(string.format(TimetoLevel.name)
	if ( addOnName ~= TimetoLevel.name ) then
		return
	end
	
	TimetoLevel.XP = GetUnitXP('player')
	TimetoLevel.levelXP = GetNumExperiencePointsInLevel(GetUnitLevel('player')) 
	TimetoLevel.remainingXP = TimetoLevel.levelXP - TimetoLevel.XP
	TimetoLevelCounter:SetText(string.format(addOnName))

	EVENT_MANAGER:UnregisterForEvent(TimetoLevel.name, EVENT_ADD_ON_LOADED)
end


EVENT_MANAGER:RegisterForEvent(TimetoLevel.name, EVENT_ADD_ON_LOADED, TimetoLevel.Initalize)
The above code works fine if I do:
Code:
if ( addOnName ~= "TimetoLevel" ) then
		return
	end
Here is my text file as well
Code:
## Title: TimetoLevel
## Description: Devisaurs Time to Level Version 1.0
## APIVersion: 100019

TimetoLevel.lua
TimetoLevel.xml

Last edited by Devisaur : 06/16/17 at 06:40 PM. Reason: Solution found
  Reply With Quote
 

ESOUI » Developer Discussions » Lua/XML Help » Variable Initalization Issue


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