Thread Tools Display Modes
07/11/15, 06:37 AM   #1
Keldor
 
Keldor's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2015
Posts: 101
List of all Zone Names

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
  Reply With Quote
07/11/15, 06:49 AM   #2
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
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
07/11/15, 07:06 AM   #3
Keldor
 
Keldor's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2015
Posts: 101
Originally Posted by votan View Post
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.
Thanks votan,

this is very similar to my idea, I will give it a try.

Keldor
  Reply With Quote
07/11/15, 08:51 AM   #4
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Zone names by zoneIndex:
http://www.esoui.com/forums/showpost...3&postcount=13
  Reply With Quote
07/11/15, 12:03 PM   #5
Keldor
 
Keldor's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2015
Posts: 101
Originally Posted by Garkin View Post
Hi Garkin,

thanks it was very useful for me.

Keldor

Last edited by Keldor : 07/11/15 at 01:33 PM.
  Reply With Quote
07/11/15, 01:33 PM   #6
Keldor
 
Keldor's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2015
Posts: 101
Hi again,

is there a similar way to export all the titles not only the titles of the current character?
I've found now way to export all titles.

Keldor
  Reply With Quote
07/11/15, 01:39 PM   #7
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
I am not 100% sure, but I think they are all tied to achievements.
You could try to iterate over all of them and use
Code:
GetAchievementRewardTitle(integer achievementId)
    Returns: boolean hasRewardOfType, string titleName
to get their name
  Reply With Quote
07/11/15, 02:37 PM   #8
Keldor
 
Keldor's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2015
Posts: 101
Originally Posted by sirinsidiator View Post
I am not 100% sure, but I think they are all tied to achievements.
You could try to iterate over all of them and use
Code:
GetAchievementRewardTitle(integer achievementId)
    Returns: boolean hasRewardOfType, string titleName
to get their name

Nice idea it works great. I've to export the titles as female and male in every language because in german you have different variations of the titles. I used this code to export the titles.

Lua Code:
  1. local gameLang = GetCVar("Language.2")
  2. local gender = GetUnitGender("player")
  3.  
  4. if(type(TitleExport.savedVariables.Titles) == "nil") then
  5.     TitleExport.savedVariables.Titles = {}
  6. end
  7.  
  8. if(type(TitleExport.savedVariables.Titles[gender]) == "nil") then
  9.     TitleExport.savedVariables.Titles[gender] = {}
  10. end
  11.  
  12. for i=1,9000 do
  13.     local hasRewardOfType, titleName = GetAchievementRewardTitle(i)
  14.  
  15.     if(hasRewardOfType == true) then
  16.        
  17.         if(type(TitleExport.savedVariables.Titles[gender][i]) == "nil") then
  18.             TitleExport.savedVariables.Titles[gender][i] = {}
  19.         end
  20.  
  21.         TitleExport.savedVariables.Titles[gender][i][gameLang] = titleName
  22.     end
  23. end
  Reply With Quote
07/11/15, 03:19 PM   #9
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
Looks fine.

I would not use a constant number of achievements though.
Who knows how many we might get in the future.

Maybe something like this (untested)?
Lua Code:
  1. local function ExportTitle(achievementId)
  2. -- your export code here
  3. end
  4.  
  5. for topLevelIndex=1, GetNumAchievementCategories() do
  6.   local _, numSubCategories, numAchievements = GetAchievementCategoryInfo(topLevelIndex)
  7.   for achievementIndex=1, numAchievements  do
  8.     local achievementId = GetAchievementId(topLevelIndex, nil, achievementIndex)
  9.     ExportTitle(achievementId)
  10.   end
  11.   for subCategoryIndex=1, numSubCategories do
  12.     local _, numAchievements = GetAchievementSubCategoryInfo(topLevelIndex, subCategoryIndex)
  13.     for achievementIndex=1, numAchievements  do
  14.       local achievementId = GetAchievementId(topLevelIndex, categoryIndex, achievementIndex)
  15.       ExportTitle(achievementId)
  16.     end
  17.   end
  18. end
  Reply With Quote
07/12/15, 06:58 AM   #10
Keldor
 
Keldor's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2015
Posts: 101
This was the easiest way to get all achievements. In my Script it was set to 999999 to check a large range of available IDs.

I've attached two files with exported zones and titles from my ESO-Database MySQL Tables.
The files are coma separated and UTF-8 w/o BOM encoded.

Keldor
Attached Files
File Type: txt eso_title.txt (3.7 KB, 799 views)
File Type: txt eso_zone.txt (27.3 KB, 1097 views)

Last edited by Keldor : 07/12/15 at 07:02 AM.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » List of all Zone Names


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