Thread Tools Display Modes
11-17-10, 06:10 AM   #1
Crober
A Murloc Raider
 
Crober's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 9
savedVariable help

I am trying to get the alpha and scale to load from my savedVariable and can't figure it out. They are included in the table with others that are working just fine.

Code is here :http://lua.pastey.net/143016-mm9g

The lines I'm having confusion on are 93 & 109.

I get no errors the way it's written right now, but the scale and alpha are reset to 1 on reload/log.

I have tried alphaSlider:SetValue(HPIDB.alpha) and get the "attempt to index global 'HPIDB' (a nil value)" error.
  Reply With Quote
11-17-10, 09:08 AM   #2
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
You have to wait for the event "ADDON_LOADED" (or others that are fired later in the loading process) before you can use the saved variables.

Edit: http://www.wowpedia.org/AddOn_loading_process
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
11-17-10, 04:14 PM   #3
Crober
A Murloc Raider
 
Crober's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 9
Thanks for the info, I am still pretty new to Lua. I added a check to only do stuff on the PLAYER_LOGIN event and that fixed the nil issue, but now when I reference the savedVariable table I get "Usage alphaSlider_GlobalName:SetValue(value)" as an error.

updated code:http:http://lua.pastey.net/143043
  Reply With Quote
11-17-10, 05:16 PM   #4
Dorwido
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Apr 2006
Posts: 54
as Rilgamon already said you need to watch for the event "ADDON_LOADED" and check if it was your addon loaded, before the saved variables are ready.

Code:
function events:PLAYER_LOGIN(...)  
22	  
23	if event == "PLAYER_LOGIN" then
and that will be always false because the variable event isnt declared

Last edited by Dorwido : 11-18-10 at 03:15 AM.
  Reply With Quote
11-17-10, 05:21 PM   #5
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
Check what value HPIDB.alpha has and compare what value you expect it to have

Tracing with a print(HPIDB.alpha) in different places to see where it has the
right value und where it goes wrong.
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » savedVariable 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