Thread Tools Display Modes
Prev Previous Post   Next Post Next
05-24-24, 01:51 AM   #6
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,253
I found part of the problem, which is a display bug rather than a table function bug. On line 368 of Core-Mainline.lua I localize a table's keys but do not check for value type.

That means keys with nil values are being localized, which shouldn't happen, which means the output table included nil values for keys.

I am about to try this new version, renamed to reflect what the function does. From there, I will continue testing the table functions SDPhantom linked.

Old version because line number change:
Lua Code:
  1. -- translate input table and return localizations
  2. function addon:TranslateTable(inputTable)
  3.     -- check inputTable for validity
  4.     if not inputTable or type(inputTable) ~= "table" then
  5.         error(":TranslateTable, 'inputTable' table expected, got %s", 2):format(type(inputTable))
  6.     end
  7.     local outputTable = {}
  8.     for index in pairs(inputTable) do
  9.         outputTable[index] = L[index]
  10.     end
  11.     return outputTable
  12. end

New version:
Lua Code:
  1. -- translate input table and return localizations for keys
  2. function addon:LocalizeTableKeys(inputTable)
  3.     -- check inputTable for validity
  4.     if not inputTable or type(inputTable) ~= "table" then
  5.         error(("'inputTable' table expected, got type '%s'"):format(type(inputTable)), 2)
  6.     end
  7.     local outputTable = {}
  8.     for key, value in pairs(inputTable) do
  9.         if type(value) ~= "string" or type(value) ~= "boolean" or type(value) ~=  "nil" then
  10.             error(("Expected string, boolean, or nil for 'value' in key '%s', got type '%s'"):format(key, type(value)), 2)
  11.         end
  12.         if value ~= nil then
  13.             outputTable[key] = L[key]
  14.         end
  15.     end
  16.     return outputTable
  17. end

Last edited by myrroddin : 05-24-24 at 02:08 AM. Reason: compare old version to new version of the function
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Issue #1: reloading UI undoes table removal


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