Thread Tools Display Modes
10-17-16, 11:18 PM   #1
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
Could I get some recommendation of nicely(?) written addons?

Hi all,

After few weeks of playing with Lua and WoW, I am now able to create some really simple addons that I would personally use.

Many thanks to those who helped me learning

So... I know that there are tons of great addons, but I guess being "great" (good functionality, fancy design, etc.) does not mean its code or structure are straightforward and easy to understand.

Thus, as the title says could I get some recommendation regarding an addon that I could go over its code and structure so I can improve my skills and learn new things?

Thank you!
  Reply With Quote
10-18-16, 12:30 AM   #2
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
I am by no means the best code writer there is but in my humble opinion I think my code has evolved to the better over time. You can see that by comparing code I wrote over the time being: https://github.com/zorker/rothui

I wrote most of my 7.0 addons from scratch and am pretty happy with how everything turned out so far.

Addons I'm most proud of are rLib, oUF_Simple, rActionBar, rBuffFrame and rButtonTemplate.

That being said. I write small addons with no ingame configuration.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
10-18-16, 04:27 AM   #3
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,323
I can't say that I've made any groundbreaking addons either. I'd say only 10% of my code has ever made it to release. This is because most of what I code is to tweak the behavior of the Default UI or write tools to help with addon development.

If you're to use my code as examples, try to find any of my posts where I write sample code to help others on the forums. The reason being is I tend to have a different commenting behavior between writing an addon for myself and writing code to help someone else. I'm a lot more verbose when posting code, explaining what every block of code is doing and why I chose to do it that way. When I write code for myself, I only write down notes on obscure code that solves a complex problem.
__________________
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
10-18-16, 06:20 PM   #4
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
Originally Posted by zork View Post
I am by no means the best code writer there is but in my humble opinion I think my code has evolved to the better over time. You can see that by comparing code I wrote over the time being: https://github.com/zorker/rothui

I wrote most of my 7.0 addons from scratch and am pretty happy with how everything turned out so far.

Addons I'm most proud of are rLib, oUF_Simple, rActionBar, rBuffFrame and rButtonTemplate.

That being said. I write small addons with no ingame configuration.
Hi zork,

Thank you for your reply!

I still remember your oUF_Doom example

At that time, I had a bit of difficulties to understand what your code actually does, but now I am quite confident with it and I've finished my oUF layout which I am pretty happy with.

Those list of projects would be a great starting point for me to go over with!

I was actually willing to create custom action bars with LibActionButton, so I guess rActionBar and rButtonTemplate be great example here

Also, I am looking forward to see your oUF nameplate module (or element) to be officially released

Originally Posted by SDPhantom View Post
I can't say that I've made any groundbreaking addons either. I'd say only 10% of my code has ever made it to release. This is because most of what I code is to tweak the behavior of the Default UI or write tools to help with addon development.

If you're to use my code as examples, try to find any of my posts where I write sample code to help others on the forums. The reason being is I tend to have a different commenting behavior between writing an addon for myself and writing code to help someone else. I'm a lot more verbose when posting code, explaining what every block of code is doing and why I chose to do it that way. When I write code for myself, I only write down notes on obscure code that solves a complex problem.
Hi SDPhantom,

Thank you for your comment!

Believe it or not, I was actually going through your comments as well as Phanx's

Also, some of your addons like 'TrainAll' and 'SlashHelp' look pretty simple but really handy.

I guess they could also be good references for those newb developers like me

Thank you!
  Reply With Quote
10-18-16, 07:34 PM   #5
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,323
TrainAll and MapCoords are pretty straightforward while SlashHelp is likely to go over your head, especially the scanner code that supports direct hash injection. I've never seen any example in which an addon has used this method to register slash commands, but it is possible and a lot more efficient than the standard method.
__________________
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
10-18-16, 10:39 PM   #6
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
Yeah... looks like I've over-estimated myself by only looking at SlashHelp.lua file D:...

I'm not sure whether I would be able to understand or not, what fact would it make that particular method be more efficient than the standard method?

Last edited by Layback_ : 10-18-16 at 10:47 PM.
  Reply With Quote
10-18-16, 11:55 PM   #7
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,323
The standard way of registering slash commands is to register a function with a command token in SlashCmdList and define the actual slash commands by writing to any number of globals.

Code:
SlashCmdList["EXAMPLECOMMAND"]=function(message,editbox)
	print("This is an example of a slash command");
end;
SLASH_EXAMPLECOMMAND1="/examplecommand";
SLASH_EXAMPLECOMMAND2="/examplecmd";
The way the game used to handle these is when you typed a slash command, it would scan though all registered tokens in SlashCmdList and look to see if a corresponding SLASH_<token><index> global matched. If one existed, it would cache the function given to the slash command in hash_SlashCmdList to speed up further executions of the same command.

In the example above, after running /examplecommand, there would now be an entry in hash_SlashCmdList that pointed to your function at that key.

The way the game processes commands now is fundamentally the same, though it is more aggressive at it and does so in a progressive manner. The idea of direct hash injection is to skip the entire scanning process by writing slash command functions directly into the command cache, hash_SlashCmdList.

Code:
local function ExampleCommand(message,editbox)
	print("This is an example of a slash command");
end
hash_SlashCmdList["/EXAMPLECOMMAND"]=ExampleCommand;
hash_SlashCmdList["/EXAMPLECMD"]=ExampleCommand;
This example produces the same result as the last one using much less resources in its initialization since it is essentially ready to run immediately without further processing.
Note: Unlike the first example, the slash commands in the second example are required to be upper case or they won't be found.
__________________
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)

Last edited by SDPhantom : 10-19-16 at 12:04 AM.
  Reply With Quote
10-19-16, 12:12 AM   #8
kurapica.igas
A Chromatic Dragonspawn
Join Date: Aug 2011
Posts: 152
There is no need to do it within hash_SlashCmdList now, the ChatFrame.lua would wipe the SlashCmdList each time after they scanned it for new registered commands.

ChatFrame.lua#L2402
  Reply With Quote
10-19-16, 02:51 AM   #9
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,323
I already hinted at this change to the command processing.
Originally Posted by SDPhantom View Post
The way the game processes commands now is fundamentally the same, though it is more aggressive at it and does so in a progressive manner.

However, the point of the post was not so much to compare performance metrics as it was to explain the methods and their differences. For an addon that lists registered slash commands, it's mandatory to cover both.
__________________
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
10-19-16, 02:05 PM   #10
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
I know I'm biased about my own work but I think my API architecture is good for my UI:

https://github.com/Mayron/MayronUI-G.../MUI_Core/APIs

I use a special GUI implementation that uses Panels and Cell objects to easily construct GUI windows specific for my UI. I also wanted to challenge myself and not use AceDB and instead I've implemented my own DB which seems to be very solid on performance. I made it somewhat compatible with AceDB by naming some functions with the same names as those used in AceDB, but the underlining implementation is very different (I never looked at the AceDB code). It uses "Observer" objects that clean the DB and switch between default values to the real Saved Variable table depending on the situation.

You can also call "SetParent" so that one table in the database can be given a parent database table like a metatable would do with __index, but it can get very complex when using global, profile, and default tables etc...

Last edited by Mayron : 10-19-16 at 02:10 PM.
  Reply With Quote
10-19-16, 06:46 PM   #11
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Most of my addons are fairly straight-forward written, with comments here and there.
__________________
"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
10-19-16, 09:02 PM   #12
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
Thank you for the explanation SDPhantom!

And thank you so much to Seerah, Mayron, kurapica.igas, SDPhantom and zork for their advice and recommendation!

Please excuse me that I can't thank person by person for now as I had a small accident recently and have a cast done on my left hand just yesterday
  Reply With Quote
10-19-16, 10:48 PM   #13
kurapica.igas
A Chromatic Dragonspawn
Join Date: Aug 2011
Posts: 152
My addons are based on a C# style oop system PLoop, I should say it's useful for me to build some big projects, but also too big to share with others.

Here is an example code Scorpio.lua of my coding style, you can also find the usage style in the comments. This is my new addon framework used to replace the old one, I'd try to make the usage more simple to make it shareable.
  Reply With Quote
10-20-16, 12:54 AM   #14
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,323
For someone starting out, I would strongly advise against using 3rd party frameworks or libraries in order to properly learn WoW's specific implementation of Lua.
__________________
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

WoWInterface » Developer Discussions » Lua/XML Help » Could I get some recommendation of nicely(?) written addons?

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