How does this addon identify the level of items to sell?
JRDK92 opened this issue ยท 3 comments
Curious how it identifies gear/items to sell based on item level. Say I enter 300 ilvl or less, sell it. Where in the script, what LUA file does that?
This code block in the JunkFilter:IsJunkItem(item)
method. It only applies to soulbound equipment.
Lines 127 to 135 in 359a333
Thanks @moody. Do you have any sort of guide or manifest as to how the add-on works? I'm not trying to copy it per se, but trying to learn from it for similar tasks. I have never programmed in LUA But I've been trying to create something similar as a practice project. Just to get down the fundamentals. This has been a really good exercise in figuring it out, the one thing I was really overwhelmed by was how many different files there are broken up all over the place. For example it seems like you have each individual component of the entire user interface in its own file, and I was trying to understand how they work together
@jsauerland I don't have any additional documentation or guide for the code outside of what you can see in the repo.
Dejunk was my first real coding project when I started learning many years ago. The project has gone through several stages of refactoring and has even been rebuilt from scratch once before; a consequence of sloppy coding as I stumbled my way through learning everything.
I've added a lot more comments and documentation to the code somewhat recently, which hopefully serves useful as you look through it. Still, some sloppy code and confusing design decisions still exist in the project.
As for the UI though, I find it to be one of the most tedious aspects of making an addon. I hate using XML, so I avoided that route and just did everything in Lua. To make the UI code maintainable, I split everything into a separate file as you've noticed. A key part of this is the Widgets
module, which is just a collection of methods to create composable pieces of the UI, such as a simple frame with a backdrop. These widgets are then used to construct bigger parts of the UI, by using them as the base frame.
A good example of this would be the MainWindow
. Its base frame is a Window
widget:
Dejunk/src/ui/main-window/main-window.lua
Lines 51 to 57 in c472ddf
The Window
widget itself is based from a TitleFrame
widget (see line 46):
Dejunk/src/ui/widgets/window.lua
Lines 33 to 46 in c472ddf
A TitleFrame
widget is based from a simple Frame
widget (see line 41):
Dejunk/src/ui/widgets/title-frame.lua
Lines 27 to 41 in c472ddf
Finally, a Frame
widget is actually just a basic frame created using the WoW API (see line 35):
Dejunk/src/ui/widgets/frame.lua
Lines 24 to 35 in c472ddf
A core part of these widget methods is having only a single parameter, options
, which is a table intended to be passed from top to bottom, containing all of the properties necessary for each widget in the hierarchy.
The layers of abstraction make things easier to manage, and I think of it like Lego; small blocks connected to one another to build something much more complicated.