View Single Post
03/23/15, 01:55 PM   #10
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
You could also get around that by giving CreateDataEntry a wrapper table instead of copying the data:
Lua Code:
  1. local entry = ZO_ScrollList_CreateDataEntry(typeId, {mydata = realdata})
  2. -- it will then look like this
  3. entry = {
  4.   typeId = typeId,
  5.   categoryId = categoryId,
  6.   data = {mydata = realdata, dataEntry = entry},
  7. }
  8. -- the data.dataEntry.data.dataEntry... cycle doesn't infect realdata

Or use a metatable:
Lua Code:
  1. local mtdata = {__index = realdata}
  2. local entry = ZO_ScrollList_CreateDataEntry(typeId, setmetatable({}, mtdata))
  3. mtdata.__newindex = realdata
  4. -- it will then look like this
  5. entry = {
  6.   typeId = typeId,
  7.   categoryId = categoryId,
  8.   data = {dataEntry = entry},
  9. }
  10. -- but entry.data.thing will return realdata.thing
  Reply With Quote