View Single Post
05/30/14, 08:19 AM   #14
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Metatables

I understand that you want to store references from three different tables into the single table. If you use unique keys, it can be done using metatables. If you use just indexes (they are not unique), it will be much more complicated.

I don't know if it is exactly what you want, but I think it's worth of trying.
Lua Code:
  1. Harvest.DataStore["en"]["alikr_base"] = {
  2.    ["Aldunz"] = 3,
  3.     .........
  4. }
  5. Harvest.DataStore["de"]["alikr_base"] = {
  6.    ["Aldunz^N,in"] = 3,
  7.     .........
  8. }
  9. Harvest.DataStore["fr"]["alikr_base"] = {
  10.    ["Aldunz^M"] = 3,
  11.     .........
  12. }
  13.  
  14. Harvest.DataStore["alikr"]["alikr_base"] = {}
  15.  
  16. setmetatable(Harvest.DataStore["de"]["alikr_base"], { __index = Harvest.DataStore["fr"]["alikr_base"] })
  17. setmetatable(Harvest.DataStore["en"]["alikr_base"], { __index = Harvest.DataStore["de"]["alikr_base"] })
  18. setmetatable(Harvest.DataStore["alikr"]["alikr_base"], { __index = Harvest.DataStore["en"]["alikr_base"] })

Metatables:
http://nova-fusion.com/2011/06/30/lu...bles-tutorial/
http://lua-users.org/wiki/MetatableEvents
http://lua-users.org/wiki/MetamethodsTutorial
  Reply With Quote