WoW:API GetMapZones: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
 
m (Move page script moved page API GetMapZones to API GetMapZones without leaving a redirect)
 
(8 intermediate revisions by 8 users not shown)
Line 1: Line 1:
<center>'''GetMapZones''' ''-Documentation by [[user:Meog|Meog]]-''</center>
{{wowapi}}
Returns the zone names of a continent


Returns the zone names of one continent
  zone_1, zone_2, ..., zone_N = GetMapZones(continentIndex);
 
  GetMapZones(continent);


----
----
;''Arguments''
;''Arguments''


:Number continent
:(continentIndex)
:;continent : number of the continent you want to get the zones. The numbers equal the values of [[API_GetCurrentMapContinent]].<br>1: Kalimdor<br>2: Eastern Kingdoms
:;continentIndex : Number - Which continent to fetch the zone list from (continent indexes refer to the result of [[API GetMapContinents|GetMapContinents()]]). Currently the values are 1 for Kalimdor, 2 for Eastern Kingdoms, and 3 is for Outlands (without Twisting Nether).


----
----
;''Returns''
;''Returns''


:String zone_1, String zone_2, ..., String zone_n
:zone_1, zone_2, ..., zone_N
:;zone_i : string, holds one zone name (i is equal to the value [[API_GetCurrentMapZone]] returns)
:;zone_''i'' : String - The name of the ''i'''th zone within the continent (''i'' corresponds to the value [[API_GetCurrentMapZone|GetCurrentMapZone()]] returns)


----
----
;''Example''
;''Example 1''
 
local function LoadZones(c, ...)
for i=1,select('#', ...),1 do
c[i] = select(i,...)
end
end
local C1 = {}
local C2 = {}
local C3 = {}
local C4 = {}
LoadZones(C1,GetMapZones(1))
LoadZones(C2,GetMapZones(2))
LoadZones(C3,GetMapZones(3))
LoadZones(C4,GetMapZones(4))
 
;''Result''
The array C1 holds all a list of all zone names for Kalimdore, C2 for Eastern Kingdoms, C3 for Outland, and C4 for Northrend.
 
----
;''Example 2''
  ZoneNames = {};
  ZoneNames = {};
   
   
Line 28: Line 49:
   
   
  LoadZones(GetMapZones(2)); -- Eastern Kingdoms
  LoadZones(GetMapZones(2)); -- Eastern Kingdoms
Note that this is equivalent to
ZoneNames = { GetMapZones(2) } ;


;''Result''
;''Result''
Line 37: Line 62:


----
----
;''Description''
;''Details''


: Returns the zone names. There is a different number of zones on each continent.
: There are a different number of zones on each continent and these may change without notice as new content is added. Use the name of a zone if you wish to make your code future-proof.
----
 
{{Template:WoW API}}
: Beware : zone names depend on locale, and zone number too because GetMapZones() returns them in ''alphabetical'' order. So french and german clients do not have the zones returned in the same order than english ones, see the [[LocalizedMapZones|table of localized map zones]].

Latest revision as of 04:46, 15 August 2023

WoW API < GetMapZones

Returns the zone names of a continent

zone_1, zone_2, ..., zone_N = GetMapZones(continentIndex);

Arguments
(continentIndex)
continentIndex
Number - Which continent to fetch the zone list from (continent indexes refer to the result of GetMapContinents()). Currently the values are 1 for Kalimdor, 2 for Eastern Kingdoms, and 3 is for Outlands (without Twisting Nether).

Returns
zone_1, zone_2, ..., zone_N
zone_i
String - The name of the i'th zone within the continent (i corresponds to the value GetCurrentMapZone() returns)

Example 1
local function LoadZones(c, ...)
	for i=1,select('#', ...),1 do
		c[i] = select(i,...)
	end
end

local C1 = {}
local C2 = {}
local C3 = {}
local C4 = {}

LoadZones(C1,GetMapZones(1))
LoadZones(C2,GetMapZones(2))
LoadZones(C3,GetMapZones(3))
LoadZones(C4,GetMapZones(4))
Result
The array C1 holds all a list of all zone names for Kalimdore, C2 for Eastern Kingdoms, C3 for Outland, and C4 for Northrend.

Example 2
ZoneNames = {};

function LoadZones(...)
   for i=1, arg.n, 1 do
      ZoneNames[i] = arg[i];
   end
end

LoadZones(GetMapZones(2)); -- Eastern Kingdoms

Note that this is equivalent to

ZoneNames = { GetMapZones(2) } ;
Result
The array ZoneNames holds all available zone names of the Eastern Kingdoms:
ZoneNames[1] == "Alterac Mountains"
ZoneNames[2] == "Arathi Highlands"
...
ZoneNames[25] == "Wetlands"

Details
There are a different number of zones on each continent and these may change without notice as new content is added. Use the name of a zone if you wish to make your code future-proof.
Beware : zone names depend on locale, and zone number too because GetMapZones() returns them in alphabetical order. So french and german clients do not have the zones returned in the same order than english ones, see the table of localized map zones.