View Single Post
03-20-13, 11:05 AM   #17
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,327
Originally Posted by Nibelheim View Post
As an example:

Top of first .Lua file
Lua Code:
  1. local addon, ns = ...
  2. local Funs, Settings = unpack(select(2, ...))
  3.  
  4. Settings.defaults = {
  5.    x = 0,
  6.    y = 0,
  7. }
  8.  
  9. Funs.updateSettings = function()
  10.     -- do stuff
  11. end

Second file
Lua Code:
  1. local Funs, Settings = unpack(select(2, ...))
  2.  
  3. local Init = function()
  4.     Funs.updateSettings()
  5.     print(Settings.x, Settings.y)
  6. end

You can now access thingies from any file within your addon, as each file in your addon shares a hidden passed argument.
From the code you posted, this starts an error propagating from the following line:
Code:
local Funs, Settings = unpack(select(2, ...))
This is because the shared addon table is empty and as such, both variables will be set to nil. Further code raises an attempt to index nil error.


Originally Posted by fRodzet View Post
Ty!


Some links on where to start learning, which editors is good to use, maybe some books and other stuff would be very much appreciated! I am really in to learning this stuff, i find it very exciting!

Isn't there a very good guide out there guiding you trough every single step of creating a WoWAddOn? Like first learn you the basics of lua, then explains the control structures, etc?
The websites mentioned are a good start. I've had experience with Lua prior to playing WoW at which I've learned from the documentation on Lua's official website. Note WoW uses Lua version 5.1 now. As far as books, as you've run into before, the WoW API is constantly evolving and books and guides will eventually become outdated as time passes.


Originally Posted by Clamsoda View Post
WoWpedia is a bit more relevant than WoWwiki. I believe that WoWpedia was made, and is maintained by several people that moved on from WoWwiki(for whatever reason).
WoWWiki started out being hosted independently and was fine at that point. The problem started when they moved to be hosted by Wikia.com. From then, Wikia.com forced the site to undergo drastic layout changes many people hated, including several admins. It was then the admins branched off and made WoWPedia, which is hosted by Curse.com.

I feel like an old geezer talking about this, "I've seen some things, man. And some stuff. I wouldn't recommend it."
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote