Toggling modules with proxy table
So, as a part of my small project I'm working on a functionality to toggle modules depending on player's current specialization and here's a brief draft of what I've done so far:
Lua Code:
It's working perfectly well as I expected, BUT all those nasty for loops & if statements look so messy and I'm pretty sure I would forget what the hxxk I've done here in the close future. (I'll be changing the variable names and leave comments, tho...) It would be grateful if someone could come up with better ideas. Thank you! |
Couldn't tell for your actual question (and also I don't know what your addon is meant to actually do), but I do notice something right away:
On spec change, you enable the list (module?) for that spec, but don't disable the others (unless there's some dark magic at work in your code that I can't work out.) So if you changed specs multiple times, you'd just end up having everything enabled, rather than toggling according to spec changes. Might be worth seeing if that's not causing issues, and if it's not, then it can probably be left as-is. I just thought I'd mention it. |
I already don't know what the heck you've done there. :p
I'd do something like this very light and totally untested system that uses AceDB and replicates the basic features of AceAddon and AceEvent, plus some specialized logic to automatically toggle modules on and off based on spec: Lua Code:
And then in each module: Lua Code:
|
Quote:
So, it's like how a group of radio buttons would behave. Let's say I'm a druid and there are 4 different specs. Switching myself to feral from boomy would enable module for feral, but disable all other specs' module (guardian, resto and boomy). This is what I've been working :p |
I see you've already replied to the thread, so be aware I've edited the code in my last post several times in the meantime.
|
Quote:
I surely needed some advice, but was totally aware of that this is just a garbage :p I'm so embarrassed now :o |
Quote:
Thanks for your solution!! :banana: |
All times are GMT -6. The time now is 09:28 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI