WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Wanting to Learn How: Addons, LUA, XML (https://www.wowinterface.com/forums/showthread.php?t=37610)

Shialla 12-14-10 06:18 PM

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.

Rilgamon 12-14-10 06:26 PM

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 :)

Sythalin 12-14-10 06:29 PM

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.

nightcracker 12-14-10 06:30 PM

Except for some very specific examples you don't have to use XML for anything.

Sythalin 12-14-10 06:40 PM

Quote:

Originally Posted by nightcracker (Post 222908)
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.

Coote 12-14-10 07:07 PM

Quote:

Originally Posted by Shialla (Post 222901)
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/


Quote:

Originally Posted by Rilgamon (Post 222905)
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.


Quote:

Originally Posted by ChaosInc (Post 222907)
XML is the work of the devil in regards to addon coding, in my opinion

FQMFT

Ketho 12-14-10 07:42 PM

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
Quote:

Originally Posted by Rilgamon (Post 222905)
The best start is to "steal" code :)

this, this, and this

Seerah 12-14-10 10:34 PM

Quote:

Originally Posted by ChaosInc (Post 222911)
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.

Shialla 12-14-10 11:14 PM

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. :banana: Woo!

nightcracker 12-15-10 12:13 AM

Quote:

Originally Posted by ChaosInc (Post 222911)
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.

Shialla 12-15-10 07:46 PM

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?

Zidomo 12-15-10 08:59 PM

_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.

Seerah 12-15-10 09:21 PM

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

Shialla 12-15-10 10:52 PM

Quote:

Originally Posted by Seerah (Post 223081)
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. :o

Phanx 12-16-10 07:52 AM

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. :p

Mera 12-16-10 12:27 PM

Quote:

Originally Posted by Phanx (Post 223123)
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

Sythalin 12-16-10 01:27 PM

Quote:

Originally Posted by Mera (Post 223163)
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.

Xinhuan 12-16-10 09:11 PM

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.

Phanx 12-16-10 09:25 PM

Quote:

Originally Posted by ChaosInc (Post 223170)
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.

Shialla 12-18-10 11:05 AM

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. :banana:


All times are GMT -6. The time now is 12:24 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI