WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Could I get some recommendation of nicely(?) written addons? (https://www.wowinterface.com/forums/showthread.php?t=54664)

Layback_ 10-17-16 11:18 PM

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

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!

zork 10-18-16 12:30 AM

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.

SDPhantom 10-18-16 04:27 AM

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.

Layback_ 10-18-16 06:20 PM

Quote:

Originally Posted by zork (Post 319958)
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 :D

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

Quote:

Originally Posted by SDPhantom (Post 319961)
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 :D

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

Thank you!

SDPhantom 10-18-16 07:34 PM

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.

Layback_ 10-18-16 10:39 PM

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?

SDPhantom 10-18-16 11:55 PM

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.

kurapica.igas 10-19-16 12:12 AM

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

SDPhantom 10-19-16 02:51 AM

I already hinted at this change to the command processing.
Quote:

Originally Posted by SDPhantom (Post 319989)
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.

Mayron 10-19-16 02:05 PM

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

Seerah 10-19-16 06:46 PM

Most of my addons are fairly straight-forward written, with comments here and there.

Layback_ 10-19-16 09:02 PM

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

kurapica.igas 10-19-16 10:48 PM

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.

SDPhantom 10-20-16 12:54 AM

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.


All times are GMT -6. The time now is 11:34 PM.

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