Quantcast
Download
(29 Kb)
Download
Updated: 10/15/18 11:41 AM
Pictures
File Info
Compatibility:
Murkmire (4.2)
Wolfhunter (4.1)
Updated:10/15/18 11:41 AM
Created:10/15/18 11:41 AM
Monthly downloads:253
Total downloads:341
Favorites:3
MD5:
4.2
LibZone
Version: 0.2
by: Baertram [More]
LibZone
A library to help with zone information.
It contains:
-Localized zone names for the languages DE, EN, FR
-ZoneId, ZoneIndex, ZoneParentId (beginning with API100025 "Murkmire")

This library uses SavedVariables and thus needs it's own LibZone.txt manifest file!


Where is the data?
Your instance of LibZone contains 2 tables.
1 for the localized data:
LibZone.localizedZoneData[language][zoneId] = "Localized name of the zone"
-> Language = String, length 2. Example: "en", "de", "fr"
-> ZoneId = The zone's unique id which you are able to get via some API function like these ones:
Code:
* GetMapInfo(*luaindex* _index_)
** _Returns:_ *string* _name_, *[UIMapType|#UIMapType]* _mapType_, *[MapContentType|#MapContentType]* _mapContentType_, *integer* _zoneId_, *string* _description_

* GetGuildMemberCharacterInfo(*integer* _guildId_, *luaindex* _memberIndex_)
** _Returns:_ *bool* _hasCharacter_, *string* _characterName_, *string* _zoneName_, *integer* _classType_, *integer* _alliance_, *integer* _level_, *integer* _championRank_, *integer* _zoneId_

* GetFriendCharacterInfo(*luaindex* _friendIndex_)
** _Returns:_ *bool* _hasCharacter_, *string* _characterName_, *string* _zoneName_, *integer* _classType_, *integer* _alliance_, *integer* _level_, *integer* _championRank_, *integer* _zoneId_
1 for the non localized data:
LibZone.zoneData[zoneId] = {
["zoneIndex"] = zoneIndex,
["parentZone"] = zoneId of the parent Zone
}

->zoneIndex = The zoneIndex which can be determined via some API functions like these ones:
Code:
* GetCurrentMapZoneIndex()
** _Returns:_ *luaindex* _zoneIndex_

* GetZoneIndex(*integer* _zoneId_)
** _Returns:_ *luaindex* _zoneIndex_
->zoneId = see above


Usage
-Download, use as standalone library or keep (otherwise the SavedVariables are lost!) the manifest txt file and just use the library file within your addon.
-Load the library within your addon code using the versioning library libStub (included):
Lua Code:
  1. local libZone = LibStub('LibZone')

The file LibZone_Data.lua contains the localized zone names for DEn EN and FR language.
The file LibZone.lua contains functions to read this, and the other information, for your addons.

THis function will build new zone data and save them to the savedvariables. It will use the current client's language and will be run once as the library loads. So if you are playing on a non-official client language the data will be read and added to your savedvariables.
Code:
--Check and get all zone's data and save them to the SavedVariables
--Parameters:
-->reBuildNew: Boolean [true=Rebuild the zoneData for all zones, even if they already exist / false=Skip already existing zoneIds]
-->doReloadUI: Boolean [true=If at least one zoneId was added/updated, do a ReloadUI() at the end to update the SavaedVariables now / false=No autoamtic ReloadUI()]
function lib:GetAllZoneDataById(reBuildNew, doReloadUI)

Code:
--Return the zoneData of a zone, determined by help of the subZone ID.
--Parameters:
--subZoneId: Number SubZoneId
--language: String Language for the ParentZoneName
-->Returns table:
--->returnTable[number SubZoneId] = {
--->    ["parentZoneId"] = number ParentZoneId,
--->    ["name]"         = String "ParentZoneName"
--->}
--If no parent zone can be found the return value will be nil.
function lib:GetZoneDataBySubZone(subZoneId, language)

Code:
--Return existing zone/their subZone data to variables.
-- Returns the zoneData, subZoneData tables
-->Contents of zoneData:
-->zoneData = { ["name"] = String "Zone Name^n"
-->             ["zoneIndex"] = number zoneIndex
-- }
-->Contents of subZoneData:
-->subZoneData = { ["name"] = String "Sub zone Name^n"
-->                ["parentZone"] = number zoneId}
-- }
function lib:GetZoneData(zoneId, subZoneId, language)

Code:
--Show existing zone data to the chat now
--Output zone informtaion to the chat, using the zoneId, subZoneId (connected to zoneId via parentZoneId) and the language (e.g. "en" or "fr")
function lib:ShowZoneData(zoneId, subZoneId, language)

Code:
--Get the localized zone name by help of a zoneId
--zoneId: Number containing zoneId
--language: The language to use for the zoneName
--->Returns localized String of the zoneName
function lib:GetZoneName(zoneId, language)

Code:
--Get the localized zone names by help of a table containing the zoneIds
-->zoneIdsTable: Table containing a number index as key and the zoneId as value
-->e.g. zoneIdsTable = {2, 3, 36, 1200} or zoneIdsTable[1] = 1, zoneIdsTable[2] = 3, zoneIdsTable[3] = 36, zoneIdsTable[4] = 1200
--->Returns table containing the zone names
--->Key = zoneId
--->Value = table with the zoneData from the SavedVariables.
--->Example:
---->returnTable[2] = "Clean Test"
---->returnTable[3] = "Gelnumbra"
function lib:GetZoneNamesByIds(zoneIdsTable, language)


Code:
--Get the localized zone data by help of a table containing the zoneIds
-->zoneIdsTable: Table containing a number index as key and the zoneId as value
-->e.g. zoneIdsTable = {2, 3, 36, 1200} or zoneIdsTable[1] = 1, zoneIdsTable[2] = 3, zoneIdsTable[3] = 36, zoneIdsTable[4] = 1200
--->Returns table containing the zoneData
--->Key = zoneId
--->Value = table with the zoneData from the SavedVariables.
--->Example:
---->returnTable[2] = {
---->   ["name"] = "Clean Test",
---->   ["zoneIndex"] = 1,
---->},
---->returnTable[3] = {
---->   ["name"] = "Glenumbra",
---->   ["zoneIndex"] = 2,
---->}
function lib:GetZoneDataByIds(zoneIdsTable, language)
Optional Files (0)


Post A Reply Comment Options
Unread 10/15/18, 11:51 AM  
Baertram
 
Baertram's Avatar
AddOn Author - Click to view AddOns

Forum posts: 1800
File comments: 1953
Uploads: 48
Be sure to include the LibZone.txt file in your addon if you embed this library into your addon or your savedvariables won't work properly!
-> Be sure to remove the LibStub folder and files + the call to it from LibZone.txt as well if you already have LibStub added to your addon then!

And do not forget to add LibZone to your addon's .txt manifest file:
##OptionalDependsOn: LibZone

Non-official Game client languages or client language "jp"
If you are using a game client which uses another language then "de", "en", "fr" feel freee to send me your SavedVariables so I can add your client language to the LibZone_Data.lua file for next versions!
Last edited by Baertram : 10/15/18 at 11:52 AM.
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: