View Single Post
11/18/14, 09:51 PM   #10
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Your original code modified to use table.insert (I assume that your table with options is called "optionsTable"):
Lua Code:
  1. for _, craftKey in pairs(blackSmithingRules) do
  2.     table.insert(optionsTable, {
  3.         type = "dropdown",
  4.         name = getTranslated(craftKey),
  5.         choices = getTranslateTable(sendingType),
  6.         getFunc = function() return getTranslated(BankManager.Saved[craftKey][numProfile]) end,
  7.         setFunc = function(value) changeTranslateTable(value,craftKey,numProfile) end,
  8.     })
  9. end
This code is basically the same as was suggested by Sasky.

Modified code if you use metatable as it is in HarvestMaps addon (again, I assume that you use "optionsTable"):
Lua Code:
  1. for _, craftKey in pairs(blackSmithingRules) do
  2.     optionsTable:insert({
  3.         type = "dropdown",
  4.         name = getTranslated(craftKey),
  5.         choices = getTranslateTable(sendingType),
  6.         getFunc = function() return getTranslated(BankManager.Saved[craftKey][numProfile]) end,
  7.         setFunc = function(val) changeTranslateTable(val, craftKey, numProfile) end,
  8.     })
  9. end
  Reply With Quote