Thread Tools Display Modes
04/16/14, 03:36 AM   #1
BadVolt
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 74
LUA table: link to self as value

Hello, guys. I'm developing addon MobileBank and I'm stuck... need some advice and fresh look.
So, what do we have. We have "ZO_PlayerBankBackpack.data" table which contents item information about guildbank items. I want to dump it and then give player possibility to open his guildbank in wild. No deposit/withdraw ofc.
It looks simple enought: create black table and use for k,v in pairs()... BUT. Developers "data" table have several links to other controls. And that's worst of it: link to self. Dunno why did developers did such a thing, but it have no scence for me at all
So, when trying do dump such table, it becomes cyclic, unable so save and crashes client.

Any ideas how to dump such table without linking to itself? May be loading emply data and replace values after table created or etc? If so, how can it be done? Anyway, need your advice.

Screenshot of Zgoo (God bless creators of this addon) is below.

Last edited by BadVolt : 04/16/14 at 03:38 AM.
  Reply With Quote
04/16/14, 08:19 AM   #2
Vicster0
 
Vicster0's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 82
I kind of do this in my addon InventoryInsight. You may want to go take a look at the code to see how I do it.

There are probably many ways to skin this cat.
  Reply With Quote
04/16/14, 08:30 AM   #3
BadVolt
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 74
Originally Posted by Vicster0 View Post
I kind of do this in my addon InventoryInsight. You may want to go take a look at the code to see how I do it.

There are probably many ways to skin this cat.
Thanks. Yeah, I saw our addons are most similar. I'l sure get a closer look.

While waiting for more experienced author, I managed to find it myself
If someone also need this solution:

Lua Code:
  1. TempTable={}
  2. TempTable.data=123
  3. TempTable.self=TempTable

TempTable=>
TempTable.data=123
TempTable.self=
{
TempTable.data=123,
TempTable.self={...}
}

Now this table links to itself.
And same way for functions

Last edited by BadVolt : 04/16/14 at 08:33 AM.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » LUA table: link to self as value


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off