Thread Tools Display Modes
12-14-10, 06:18 PM   #1
Shialla
A Deviate Faerie Dragon
 
Shialla's Avatar
Join Date: Sep 2007
Posts: 16
Arrow Wanting to Learn How: Addons, LUA, XML

So, lets a say someone who hasn't coded anything in many many years wanted to teach themselves how to make addons for WoW where would they begin? I have no knowledge of XML, just some basic HTML, coding was BASIC back in the 80's.

Any ideas? Help? Suggestions? (Other than don't bother) I'd really like to start trying to learn, as I have a lot of free time.
  Reply With Quote
12-14-10, 06:26 PM   #2
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
The best start is to "steal" code

Grab some small addons that only have one function and look at the code.

Some howtos

http://www.wowpedia.org/HOWTO
http://www.wowpedia.org/World_of_Warcraft_API

Next you should get a good editor like notepad++ or sth.

And when you've started come here with your problems to ask
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
12-14-10, 06:29 PM   #3
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
XML is the work of the devil in regards to addon coding, in my opinion (translate: IMO for you 1337 nerds out there).

Just with any language, start with the basics. WoWwiki has a decent startup guide here. Follow that up with the "HOWTO" sections for some more specific examples and tips/tricks.

After that, start downloading some "simpler" addons out there and open them in notepad (or whatever editor of your choosing). Examine the code. Try to follow the function flows and see how they work. This, besides for the core basics in the "Getting started", is perhaps the best option for learning as it can show you a variety of ways to do similar things but in different structures. It's my firm opinion this is actually the best way to learn how to write addons for WoW (though not the best way to learn LUA in general).

There are many others, myself included, that learned from the ground up just as you want to do. It does take some patience and dedication, but once everything "clicks", you'll find it's a lot easier than it looks. As with any coding language, the worst points are where coding can be tedious and repetitive. But in the end, you get a great feeling when it all works the way you wanted to.
  Reply With Quote
12-14-10, 06:30 PM   #4
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
Except for some very specific examples you don't have to use XML for anything.
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote
12-14-10, 06:40 PM   #5
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Originally Posted by nightcracker View Post
Except for some very specific examples you don't have to use XML for anything.
Such as? I have yet to find a single need for it.

I have found one MAJOR downside to XML that caused me to hate it; If you have any errors, your addon simply won't load.

No loading = no error messages for debugging = useless.
  Reply With Quote
12-14-10, 07:07 PM   #6
Coote
A Scalebane Royal Guard
 
Coote's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 440
Originally Posted by Shialla View Post
Any ideas? Help? Suggestions?
Don't bother.

j/k, but somebody had to say it. =P


A good start is reading up on WoWPedia and WoWProgramming. WoWPedia has a fairly decent bit of information for starting out, and the WoWProgramming book is definitely worth it if you don't mind spending $50 or so on a rather large book (it's definitely worth it, though).

http://www.wowpedia.org/Getting_star...writing_addons
http://wowprogramming.com/


Originally Posted by Rilgamon View Post
The best start is to "steal" code

Grab some small addons that only have one function and look at the code.

And when you've started come here with your problems to ask
Pretty much this. I first started out with just modifying addons, and mostly, that's still what I do. I would recommend starting out with changing up oUF layouts. Try taking something nice and simple, such as NC_KillingBlow, and making it print something on levelups, instead of killing blows.


Originally Posted by ChaosInc View Post
XML is the work of the devil in regards to addon coding, in my opinion
FQMFT
__________________

"This is the fifteen-thousandth four hundredth and ninety-eighth occurence".
  Reply With Quote
12-14-10, 07:42 PM   #7
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Where to begin?
  1. Grab a Text Editor or IDE: Notepad++ / Notepad2 / IntelliJ IDEA, etc, but NOT AddOn Studio
  2. Modify/copy other (simple) addons
  3. Read the Getting started with writing addons Tutorial
Optionally, get on IRC: irc://chat.freenode.net #wowuidev, #wowace, #wowpedia
Buy the books: Programming in Lua, World of Warcraft Programming
References:
ps: "anything" that can be done with XML, can be done in Lua, so you don't really need to know XML to make an addon
Originally Posted by Rilgamon View Post
The best start is to "steal" code
this, this, and this

Last edited by Ketho : 12-16-10 at 09:19 AM.
  Reply With Quote
12-14-10, 10:34 PM   #8
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by ChaosInc View Post
Such as? I have yet to find a single need for it.

I have found one MAJOR downside to XML that caused me to hate it; If you have any errors, your addon simply won't load.

No loading = no error messages for debugging = useless.
Creating templates is one.

You can check your FrameXML.log file in the Logs folder for XML loading errors. Other than that, you can run the XML file through a compiler - the same kind that you would use to check web XML code through - to check for syntax errors.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
12-14-10, 11:14 PM   #9
Shialla
A Deviate Faerie Dragon
 
Shialla's Avatar
Join Date: Sep 2007
Posts: 16
Thumbs up

I really appreciate all the helpful replies and advice. It's great to see such a helpful and friendly community! I guess I have my work cut out for me starting tomorrow. Woo!
  Reply With Quote
12-15-10, 12:13 AM   #10
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
Originally Posted by ChaosInc View Post
Such as? I have yet to find a single need for it.

I have found one MAJOR downside to XML that caused me to hate it; If you have any errors, your addon simply won't load.

No loading = no error messages for debugging = useless.
There is another one, (easily) add keybinding slots to the escape menu bindings screen.
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote
12-15-10, 07:46 PM   #11
Shialla
A Deviate Faerie Dragon
 
Shialla's Avatar
Join Date: Sep 2007
Posts: 16
So I have hit my first little snag.

IN another thread Phanx, kind soul that he is, gave me some simple instructions on how to fix a particular addon that is broken. He told me to change specific line numbers. So I installed Notepad++ and got to work. The one problem, Notepad++ line numbers and the ones Phanx gave me didn't line up.

I eventually figured out that Notepad++ was adding blank lines between each line of the code. So my questions are:
  • Is Notepad++ the way to go for editing LUA and XML?
  • How do I make it not add those extra lines when I open a file?
  • Is there some plugin or other I should get for working on WoW stuff?
  Reply With Quote
12-15-10, 08:59 PM   #12
Zidomo
A Cliff Giant
 
Zidomo's Avatar
Join Date: Apr 2006
Posts: 76
_Any_ text editor that can open and save UTF-8/UTF-8 signature encoded files properly (along with ANSI, etc.) is "the way to go for editing LUA and XML".

Windows Notepad "can save" UTF-8 files, but its a giant hassle to work with. It can destroy files that originally have Unix or Mac newlines, below Vista it has problems with detecting Unicode, it has no line numbering, etc.. So basically, anything is better than it.

Notepad++ is well regarded as its open source (free) and has a ton of features, plugins and so on. Also nice for LUA editing as it has plugins that can highlight, etc..

But as noted, its got a giant ton of features. Also has a good built-in help file along with tons of online resource help. If its too much for you, might want to ask if LUA editing/programming is really something you want to start doing.

If you really (really) do want to program, a lighter weight text editor mentioned above that is actually my favorite for quick work: Notepad2 (also free). It has line numbers, doesn't add "random blank lines" and is considerably simpler to get started with.

Other choices: Lua editors.
  Reply With Quote
12-15-10, 09:21 PM   #13
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
The numbers she gave you are all correct for me using Notepad++, and I have never had issues with it. Are you certain that you are comparing to the correct files? You have to look at NameViolation.lua and NameViolation.xml
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
12-15-10, 10:52 PM   #14
Shialla
A Deviate Faerie Dragon
 
Shialla's Avatar
Join Date: Sep 2007
Posts: 16
Red face

Originally Posted by Seerah View Post
The numbers she gave you are all correct for me using Notepad++, and I have never had issues with it. Are you certain that you are comparing to the correct files? You have to look at NameViolation.lua and NameViolation.xml
It is giving me the right line numbers now as well, earlier it was adding extra blank lines :P Heh, I'm a noob and probably changed some setting or other trying to figure out Notepad++ before.
  Reply With Quote
12-16-10, 07:52 AM   #15
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You may have changed how line ending markers are handled. I've never seen an editor treat a Windows line ending (CR+LF) as a double line break (Unix is LF and Mac is CR), but I suppose it's possible. You can see the opposite effect in the default Windows Notepad when you open a file with Unix or Mac line endings; it won't show any line breaks at all.

I use Notepad2. It's small (618 KB executable) and fast, and not overburdened with a bunch of features that most people will never use or even know exist. The only downside is that it doesn't include syntax highlighting for Lua, but I find syntax highlighting annoying anyway, so I don't mind the lack.
  Reply With Quote
12-16-10, 12:27 PM   #16
Mera
Retired of WoW, In ESO :)
 
Mera's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 331
Originally Posted by Phanx View Post
but I find syntax highlighting annoying anyway, so I don't mind the lack.
I find it rather important here to the point I won't code without syntax highlights
__________________
If you need to reach me I'm in ESO, @class101 or "Fathis Ules i"
addons: SpamBayes, BrokerCPU
projects: ThunderBayes
Mera[xeh]? - La CroisadeEcarlate (wow)
  Reply With Quote
12-16-10, 01:27 PM   #17
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Originally Posted by Mera View Post
I find it rather important here to the point I won't code without syntax highlights
Agreed. It's a nice utility to avoid simple syntax errors or find variables/strings at a glance. Using NP++ (I'm one that uses it for more than lua), the fact that it highlights corresponding open/close braces has saved me plenty of headaches, both school work and add-on coding.
  Reply With Quote
12-16-10, 09:11 PM   #18
Xinhuan
A Chromatic Dragonspawn
 
Xinhuan's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 174
The most important feature I find in Notepad++ is really that when you select (highlight) a word (a variable name) or a number, it automatically also highlights the same word/number everywhere in the document.

This allows me to see where and how a variable is used within a function quickly, and assists greatly in the process of code understanding when reviewing code. It also helps immensely when refactoring code.

Kinda wish Visual Studio will add this.
__________________
Author of Postal, Omen3, GemHelper, BankItems, WoWEquip, GatherMate, GatherMate2, Routes and Cartographer_Routes
  Reply With Quote
12-16-10, 09:25 PM   #19
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by ChaosInc View Post
the fact that it highlights corresponding open/close braces has saved me plenty of headaches, both school work and add-on coding.
Notepad2 also does this, but as a separate feature from syntax highlighting, so it's not required to use one to have the other.
  Reply With Quote
12-18-10, 11:05 AM   #20
Shialla
A Deviate Faerie Dragon
 
Shialla's Avatar
Join Date: Sep 2007
Posts: 16
First project is Phanx walking me through fixing NameViolation, and its actually helping me some. I am sort of starting to get a basic idea of how LUA interacts with itself and XML. So I wanted to thank Phanx and all of you for the great advice and help here.

Next project will be as was suggested find a simple addon that does one thing and pick it apart, play with it (break it) and see how it works.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Wanting to Learn How: Addons, LUA, XML

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