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! |
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. |
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. |
Quote:
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:
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! |
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.
|
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? |
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) 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) Note: Unlike the first example, the slash commands in the second example are required to be upper case or they won't be found. |
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 |
I already hinted at this change to the command processing.
Quote:
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. |
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... |
Most of my addons are fairly straight-forward written, with comments here and there.
|
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 :( |
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. |
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