View Single Post
06/09/20, 08:13 AM   #3
stolen6394
Join Date: Jun 2020
Posts: 3
That really helped

Thanks to:

Originally Posted by Dolgubon View Post
MyAddOnTable needs to not be local. My guess is that's what's going on.
A better way to check the value at that time than what you're doing, is to add pChat as an optional dependency, and then you can use d() directly within the OnInitialized tag.
I didn't know that d() comes from pChat. lol I thought the function is one of built-in log functions provided by ZOS. silly me.

The culprit was me that messed things up (of course there is no one but obviously me ).

Here's the story:

I was writing an AddOn and feeling a mixture of chaos coming from the unfamiliar syntax of Lua and the pure joy of exploring this new area. Most of the time, I was testing some snippets by using "/script" command and copy the snippets to the AddOn if the test passed. Running "/reloadui" took soo long enough to get me exhausted, so I unloaded all the addons except for mine.

In the middle of the tests, I was tempted to make each UI controls access to the source code, instead of having them being accessed by the source code.

So I wrote "BAR = MyAddOnTable" in OnInitialized of the Label that I mentioned before.

And after some code works in lua, I got back to the xml, found OnInitialized of TopLevelControl empty, thinking "where is the code gone...? ugh...", and wrote "BAR = d(MyAddOnTable)" there in order to see if the result tells me it's a table, nevertheless, the Lable was where I supposed to see at the first place, not the TopLevelControl.

Since callbacks of OnInitialized are invoked in order from leaves to root (the moment that I figured this out is not far from the present), "BAR = MyAddOnTable" from Label was invoked first, and then "BAR = d(MyAddOnTable)" was invoked, overwriting with nil because I unloaded all addons including pChat.

Then I decided to post here with my English writing skills that are still taking over an hour for what I am writing now, so here I am.

Anyway, I am glad to learn things from this adventure.

Thanks.
  Reply With Quote