When converting a macro into an addon, there are two essential things to consider:
An addon runs inside the lua environment, and thus shouldn’t have /run or /script commands. You can save remove all ‘/run’ from the code.
Your addon will load before the UI is done loading, meaning some components may not be available yet. To circumvent this, hook up to the PLAYER_ENTERING_WORLD event which is triggered after everything has loaded, and run your addon code then.
Thanks a lot with the tips.
Now everything looks to work but the place of the debuffs.
Because there is no debuff active when I log in.
This is the Error that pops up:
Message: Interface\AddOns\ZandratarUI\code.lua:34: attempt to index global ‘DebuffButton1’ (a nil value)
Time: Sun Jan 13 18:13:44 2019
Count: 1
Stack: Interface\AddOns\ZandratarUI\code.lua:34: attempt to index global ‘DebuffButton1’ (a nil value)
Interface\AddOns\ZandratarUI\code.lua:34: in function <Interface\AddOns\ZandratarUI\code.lua:3>
Locals: (*temporary) = nil
(*temporary) = nil
(*temporary) = “TOP”
(*temporary) = -190
(*temporary) = -10
(*temporary) = “attempt to index global ‘DebuffButton1’ (a nil value)”
EDIT: Also after loading a screen (not the first time) the buffs go back to their default place.
EDIT: I changed the event to LOADING_SCREEN_DISABLED seems to be working for now. Only the error for the debuff is still poping up on first loading into the game.
P.S.: Anyone with suggestion how to remove this error?
Thanks in advance.