View Single Post
05/01/20, 07:13 AM   #24
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
I'm having a look and what I'd change at first would be remove the RemiCustomAddon: stuff and the self as you only have defined RemiCustomAddon as a table {} and not as an object. And currently you mix it with RemiCustomAddon:Initialize but RemiCustomAddon.SaveBagPosition etc.


: is used for an object oriented apporach, where . is used if you simply use a table.
You can do both but it makes no sence to define something as a "class" or object if you are not going to reuse it somehow.
And might get you into trouble with the parameters of your functions.

For the begining I'd stay at RemiCustomAddon.functionName and RemiCustomAddon.variableName instead of using self etc.

I'll make a code change, fix the found global leaking variabls and send you the zip file here after a test.

Edit:
Correct me guys if there is an easier way:
You currently use only 1 top level control for both indicators. This will not work as you got 1 surrounding top level control which needs to be the same size as your screen to make the 2 labels movable in it.
You should use 2 tlcs, and do not connect them. One for each label you want to move. Only anchor the 1 label to each tlc then. And do not use the OnMoveStop of the label but the tlc.

Else the one big TLC will be above all other controls on your UI starting to trouble all other addons + vanilla UI.

Edit2:
Found the basic problem in your code, I think.
Your XML label controls and indicator controls got fixed names like "<Control name="FightIndicator" but they are below the toplevelcontrol.
So if you use GetControl(TLCcontrol, "FightIndicator") it will not be found!
It needs the $(parent) in the XML or lua name!

<Control name="$(parent)FightIndicator"

Only this way you can use GetControl(parent, childName) or you need to use GetControl(childName) directly.
$(parent) will be a replacement for the name of the parent control, in this case it'll be "RemiCustomAddonIndicators" and the subcontrols (childs) will have a name like RemiCustomAddonIndicatorCombatFightIndicator then.

And you do not concatenate strings with the + in lua but with ..
Wrong: "Your bag is almost full! " + tostring(itemSpace)
Corect: "Your bag is almost full! " .. tostring(itemSpace)

If you install LibDebugLogger and DebugLogViewer addons you'd see all these error messages in the DebugLogViewer quicklog (bottom right of your screen) or in the DebugLogViewer UI, even if it happens before event_player_activated.

Last edited by Baertram : 05/01/20 at 08:11 AM.
  Reply With Quote