ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   List of all Zone Names (https://www.esoui.com/forums/showthread.php?t=4883)

Keldor 07/11/15 06:37 AM

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

votan 07/11/15 06:49 AM

Quote:

Originally Posted by Keldor (Post 21953)
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.

Keldor 07/11/15 07:06 AM

Quote:

Originally Posted by votan (Post 21955)
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. :D

Keldor

Garkin 07/11/15 08:51 AM

Zone names by zoneIndex:
http://www.esoui.com/forums/showpost...3&postcount=13

Keldor 07/11/15 12:03 PM

Quote:

Originally Posted by Garkin (Post 21958)

Hi Garkin,

thanks it was very useful for me.

Keldor

Keldor 07/11/15 01:33 PM

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

sirinsidiator 07/11/15 01:39 PM

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

Keldor 07/11/15 02:37 PM

Quote:

Originally Posted by sirinsidiator (Post 21969)
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

sirinsidiator 07/11/15 03:19 PM

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

Keldor 07/12/15 06:58 AM

2 Attachment(s)
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


All times are GMT -6. The time now is 01:25 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI