How do I reference an option from another file?
Setting up interface options panel for the addon.
My previous issues are all solved and I will share the addon with you guys once the interface options panel is done. File 1: Lua Code:
File 2: Lua Code:
Variables from the first file that I want to use on the second file: TESTVARIABLE, alpha, fadealpha. I've read plenty of addon files but they are all confusing to me because each addon creates the interface options panel in a different way and I have a really hard time identifying when they're using the configuration variables. |
Lua Code:
Every file loaded has access to two variables. The first is the addon name and the second is a shared namespace ( a table ). Put the data or functions you want to share into the addonNamespace. |
Every .lua file, not .xml files.
|
And to clarify, they must be loaded by the same .toc file in the same folder.
|
Ok, I read about the addonTable and I think I understood that. I just need to put that line and then just put addonTable before any variable I want to use, right? Like addonTable.alpha and addonTable.fadealpha.
But I still need to make an interface options stuff. I'm taking the config.lua file from Mapster: Lua Code:
From reading it I can understand that there's this MAP_FADE_TEXT variable thing with SetCVar("mapFade"). How would I make that useful in the Hello World example I first posted? Something like 'if addonTable.SetCVar("mapFade") = 1 then print("Hello World!") end'? I'm including this in my .toc already: Code:
#@no-lib-strip@ |
I am not adding to your original question. However, in your ToC file, you need to load the Ace libraries in the same order as listed in the Ace3.toc, which, I think, is the same order as the API documentation.
You might already be doing that, but just throwing it out there. |
Quote:
|
First, the SetCVar function is its own function, not defined/stored as part of your addon table.
Second, SetCVar sets a CVar. You need to get it's value. |
Quote:
You'd get more help if you put more effort into your posts and use addons like BugSack / Bugger to catch errors http://meta.stackexchange.com/questi...ampire-problem |
I'd suggest looking at some documentation for the WoW API functions you are using. The Get/SetCVar functions can only be used to look up and set specific built-in game options. They have nothing to do with addon options or saving addon settings.
http://wow.gamepedia.com/API_SetCVar It seems like your goal is to save addon settings, and be able to refer to them later. Assuming that's correct, you should look at tutorials related to that goal, like this one: http://wow.gamepedia.com/Saving_vari..._game_sessions I'd strongly advise against copying and pasting large chunks of code from other addons (eg. Mapster's options table) that you don't understand and trying to use that as a base for your own addon -- that's a recipe for frustration and not actually learning or accomplishing anything. I'd also advise against using large libraries (eg. AceConfig) until you have a better understanding of the underlying concepts (eg. writing to and reading variables in Lua in general, and saving variables between sessions in a WoW addon in particular). Start with something simpler, like saving one setting, and then work your way up to complex nested options if that's your end goal. If you have no programming experience at all (which seems like the case since you're having trouble with writing/reading variables, which is a very basic programming concept) I'd suggest finding a beginner's tutorial. You may not be able to find one for Lua specifically, but any scripting language -- JavaScript or Python, for example, will both have lots of tutorials out there -- will give you a better foundation, so you'll at least be able to understand the terms used in API documentation, and have a better idea of what to ask for help with. |
All times are GMT -6. The time now is 11:58 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI