View Single Post
11/19/14, 11:38 AM   #11
SnowmanDK
 
SnowmanDK's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 161
Originally Posted by Garkin View Post
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
I used HarvestMap as template yes, and my table is called "optionsTable".
This part works fine with no issues:
Lua Code:
  1. optionsTable:insert({ --[16] --> Stacks Rules submenu <--
  2.         type = "submenu",
  3.         name = getTranslated("subMenuStacksRules"),
  4.         tooltip = getTranslated("subMenuStacksRulesTooltip"),
  5.         controls = {
  6.             {--[16.1]
  7.                 type = "dropdown",
  8.                 name = getTranslated("fillStacks"),
  9.                 tooltip = getTranslated("fillStacksTooltip"),
  10.                 choices = getTranslateTable(sendingType),
  11.                 getFunc = function() return getTranslated(BankManager.Saved["fillStacks"][numProfile]) end,
  12.                 setFunc = function(value) changeTranslateTable(value,"fillStacks",numProfile) end,
  13.             },
  14.             {--[16.2]
  15.                 type = "checkbox",
  16.                 name = getTranslated("stackSizeCheckBox"),
  17.                 tooltip = getTranslated("stackSizeCheckBoxTooltip"),
  18.                 getFunc = function() return BankManager.Saved["stackSizeCheckBox"][numProfile] end,
  19.                 setFunc = function(value) BankManager.Saved["stackSizeCheckBox"][numProfile] = value end,
  20.             },
  21.             {--[16.3]
  22.                 type = "slider",
  23.                 name = getTranslated("stackSizeSlider"),
  24.                     tooltip = getTranslated("stackSizeSliderTooltip"),
  25.                 min = 1,
  26.                     max = 100,
  27.                 step = 1,
  28.                 getFunc = function() return BankManager.Saved["stackSizeSlider"][numProfile] end,
  29.                 setFunc = function(value) BankManager.Saved["stackSizeSlider"][numProfile] = value end,
  30.             },
  31.         },
  32.     })
This one fails:
Lua Code:
  1. optionsTable:insert({ --[17] --> Blacksmithing Rules submenu <--
  2.         type = "submenu",
  3.         name = getTranslated("CRAFTING_TYPE_BLACKSMITHING"),
  4.         controls = {
  5.             {--[17.1]
  6.                     type = "dropdown",
  7.                 name = getTranslated("setAllOptions") .."|r",
  8.                 tooltip = getTranslated("setAllOptionsTooltip"),
  9.                 choices = getTranslateTable(sendingType),
  10.                 getFunc = function() return "-" end,
  11.                 setFunc = function(value) setAllOptions(value,numProfile,blackSmithingRules) end,
  12.             },
  13.             for _, craftKey in pairs(blackSmithingRules) do  --<-- LINE 351
  14.                 optionsTable:insert({
  15.                     type = "dropdown",
  16.                     name = getTranslated(craftKey),
  17.                     choices = getTranslateTable(sendingType),
  18.                     getFunc = function() return getTranslated(BankManager.Saved[craftKey][numProfile]) end,
  19.                     setFunc = function(val) changeTranslateTable(val, craftKey, numProfile) end,
  20.                 })
  21.             end
  22.         },
  23.     })
with this error:
Code:
user:/AddOns/BankManagerRevived/UI/BankManagerOpts.lua:351: unexpected symbol near 'for'
Line 351 is line 13 in this cutout. I just don't get it
  Reply With Quote