View Single Post
07/11/15, 06:49 AM   #2
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 578
Originally Posted by Keldor View Post
Hi all,

I've another question.
What is the best way to loop through all the zone names of the game?

My Idea was to have Loop with i = 1 to 99999 with this function inside GetZoneNameByIndex(i)
If the return value is not empty, I will push it to my array. This should return all zone names, right?

Keldor
I use this:
Lua Code:
  1. local function GetZones()
  2.     local i = 1
  3.     local zones = data.Zones -- a table of your choice
  4.     local zbn = GetZoneNameByIndex
  5.     local zone
  6.     while true do
  7.       zone = zbn(i)
  8.       if zone == "" then break end
  9.       zones[zone] = i
  10.       i = i + 1
  11.     end
  12.   end
Don't forget: These names a raw, including localization data. You should use zo_strformat for display.
  Reply With Quote