View Single Post
12-07-14, 07:47 AM   #14
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Phanx View Post
For a one-time conversion of key names in a saved variables table, you really don't need a "proper conversion tool"... just do it quick and dirty, and don't worry about efficiency, because it doesn't matter in this context:

Code:
local function FindMapID(name)
     for i = 1, 1200 do
          if GetZoneNameByID(i) == name then
               return i
          end
     end
end

for k, v in pairs(db) do
    if type(k) == "string" then
         local id = FindMapID(k)
         if id then
              db[id] = v
              db[k] = nil
         else
              print("ERROR: no mapID found for zone name:", k)
         end
     end
end
To be honest after i started thinking about it how could i do it, i ended up with a very similar method.
My question is that is that 1200 max value for the loop is gonna be enough?
  Reply With Quote