TouristLib

From WowAce Wiki
Jump to: navigation, search

Tourist-2.0 is a library to provide information about zones and instances.

Contents

Example

local tourist = AceLibrary("Tourist-2.0")

for zone in tourist:IterateRecommendedZones() do
    print("You should go to " .. zone)
end

API Documentation

 :GetLevel("zone")

Returns the level of the specified zone

Args

"zone" 
string - zone to check

Returns

low, high

low 
number - the low-end level
high 
number - the high-end level

Remarks

This and all other functions takes the localized name of the zone, e.g. "Tirisfal Glades" or "Das Brachland", depending on your locale.

Example

local low, high = tourist:GetLevel("Tirisfal Glades")

 :GetFishingLevel("zone")

Returns the minimum level to fish a specific zone

Args

"zone" 
string - zone to check

Returns

min level or nil if you cant fish the zone

Remarks

This and all other functions takes the localized name of the zone, e.g. "Tirisfal Glades" or "Das Brachland", depending on your locale.

Example

local min_fishing = tourist:GetFishingLevel("Tirisfal Glades")


 :GetLevelColor("zone")

Returns a color based on the given zone in relation to your current level from gray to green to yellow to orange to red.

Args

"zone" 
string - zone to check

Returns

r, g, b

number [0,1] - red value
number [0,1] - green value
number [0,1] - blue value

Example

local r, g, b = tourist:GetLevelColor("Tirisfal Glades")

 :GetFactionColor("zone")

Returns a color based on the hostility of a zone. (Green, yellow, or red).

Args

"zone" 
string - zone to check

Returns

r, g, b

number [0,1] - red value
number [0,1] - green value
number [0,1] - blue value

Example

local r, g, b = tourist:GetFactionColor("Tirisfal Glades")

 :IterateZoneInstances("zone")

Returns an iterator to go through all the instances in a given zone.

Args

"zone" 
string - zone to check

Returns

Iterator - iterator to go through all the instances in a given zone.

Example

for instance in tourist:IterateZoneInstances("The Barrens") do
    print(instance)
end

 :DoesZoneHaveInstances("zone")

Returns whether a zone has any instances in it.

Args

"zone" 
string - zone to check

Returns

boolean - whether a zone has any instances in it.

Example

assert(tourist:DoesZoneHaveInstances("Tirisfal Glades")) -- it has Scarlet Monastery

 :GetInstanceZone("instance")

Returns the zone which contains the given instance.

Args

"instance" 
string - instance to check

Returns

string - the zone which contains the given instance.

Remarks

For instances that have more than one entrance, only one zone will be returned.

Example

assert(tourist:GetInstanceZone("Scarlet Monastery") == "Tirisfal Glades")

 :IterateZonesAndInstances()

Returns an iterator to go through all the possible zones and instances.

Returns

iterator - iterator to go through all the possible zones and instances.

Example

for zone in tourist:IterateZonesAndInstances() do
    print(zone)
end

 :IterateZones()

Returns an iterator to go through all the possible zones (no instances).

Returns

iterator - iterator to go through all the possible zones.

Example

for zone in tourist:IterateZones() do
    print(zone)
end

 :IterateInstances()

Returns an iterator to go through all the possible instances.

Returns

iterator - iterator to go through all the possible instances.

Remarks

Battlegrounds are seen as instances.

Example

for instance in tourist:IterateInstances() do
    print(instance)
end

 :IterateBattlegrounds()

Returns an iterator to go through all the possible battlegrounds.

Returns

iterator - iterator to go through all the possible battlegrounds.

Remarks

Battlegrounds are also seen as instances.

Example

for bg in tourist:IterateBattlegrounds() do
    print(bg)
end

 :IteratePvPZones()

Returns an iterator to go through all the zones with world PvP objectives.

Returns

iterator - iterator to go through all the zones with world PvP objectives.

Remarks

PvP zones are also seen as zones.

Example

for bg in tourist:IteratePvPZones() do
    print(bg)
end

 :IterateAlliance()

Returns an iterator to go through all the Alliance-specific zones and instances.

Returns

iterator - iterator to go through all the Alliance-specific zones and instances.

Example

for zone in tourist:IterateAlliance() do
    print(zone)
end

 :IterateHorde()

Returns an iterator to go through all the Horde-specific zones and instances.

Returns

iterator - iterator to go through all the Horde-specific zones and instances.

Example

for zone in tourist:IterateHorde() do
    print(zone)
end

 :IterateFriendly()

Returns an iterator to go through all the friendly zones and instances.

Returns

iterator - iterator to go through all the friendly zones and instances.

Example

for zone in tourist:IterateFriendly() do
    print(zone)
end

 :IterateHostile()

Returns an iterator to go through all the hostile zones and instances.

Returns

iterator - iterator to go through all the hostile zones and instances.

Example

for zone in tourist:IterateHostile() do
    print(zone)
end

 :IterateContested()

Returns an iterator to go through all the contested zones and instances.

Returns

iterator - iterator to go through all the contested zones and instances.

Example

for zone in tourist:IterateContested() do
    print(zone)
end

 :IterateKalimdor()

Returns an iterator to go through all the zones and instances in Kalimdor.

Returns

iterator - iterator to go through all the zones and instances in Kalimdor.

Example

for zone in tourist:IterateKalimdor() do
    print(zone)
end

 :IterateEasternKingdoms()

Returns an iterator to go through all the zones and instances in the Eastern Kingdoms.

Returns

iterator - iterator to go through all the zones and instances in the Eastern Kingdoms.

Example

for zone in tourist:IterateEasternKingdoms() do
    print(zone)
end

 :IterateOutland()

Returns an iterator to go through all the zones and instances in Outland.

Remarks

Only works if you have The Burning Crusade.

Returns

iterator - iterator to go through all the zones and instances in Outland.

Example

for zone in tourist:IterateOutland() do
    print(zone)
end

 :IterateRecommendedZones()

Returns an iterator to go through all the recommended zones.

Returns

iterator - iterator to go through all the recommended zones.

Remarks

Recommended in this case means that you fall within the low and high ends of the zone levels.

Example

for zone in tourist:IterateRecommendedZones() do
    print(zone)
end

 :IterateRecommendedInstances()

Returns an iterator to go through all the recommended instances.

Returns

iterator - iterator to go through all the recommended instances.

Remarks

Recommended in this case means that you fall within the low and high ends of the zone levels.
The exception being battlegrounds, where you need to be level x6 or higher, e.g. it'll recommend WSG if you're 16-19, 26-29, 36-39, 46-49, and 56-60.

Example

for instance in tourist:IterateRecommendedInstances() do
    print(instance)
end

 :HasRecommendedInstances()

Returns whether there is one or more recommended instances available.

Returns

boolean - whether there is one or more recommended instances available.

Example

assert(tourist:HasRecommendedInstances())
-- this is pretty much true if you're lvl 13 or higher
-- Horde-side or lvl 17 or higher Alliance-side

 :IsInstance("instance")

Returns whether the given instance exists and is not a regular zone.

Args

"instance" 
string - instance to check

Returns

boolean - whether the given instance exists and is not a regular zone.

Example

assert(tourist:IsInstance("Scarlet Monastery"))

 :IsZone("zone")

Returns whether the given zone exists and is not an instance.

Args

"zone" 
string - zone to check

Returns

boolean - whether the given zone exists and is not an instance.

Example

assert(tourist:IsZone("Mulgore"))

 :IsZoneOrInstance("zone")

Returns whether the given zone or instance exists.

Args

"zone" 
string - zone to check

Returns

boolean - whether the given zone or instance exists

Example

assert(tourist:IsZoneOrInstance("Mulgore") and tourist:IsZoneOrInstance("Wailing Caverns"))

 :IsBattleground("battleground")

Returns whether the given battleground exists and is not a normal instance or zone.

Args

"battleground" 
string - battleground to check

Returns

boolean - whether the given battleground exists and is not a normal instance or zone.

Example

assert(tourist:IsBattleground("Warsong Gulch"))

 :IsPvPZone("zone")

Returns whether the given zone exists and has world pvp objectives.

Args

"zone" 
string - zone to check

Returns

boolean - whether the given zone exists and has world pvp objectives.

Example

assert(tourist:IsPvPZone("Silithus"))

 :IsCity("zone")

Returns whether the given zone exists and is a city.

Args

"zone" 
string - zone to check

Returns

boolean - whether the given zone exists and is a city.

Example

assert(tourist:IsPvPZone("Undercity"))

 :IsAlliance("zone")

Returns whether the given zone is Alliance-specific.

Args

"zone" 
string - zone to check

Returns

boolean - whether the given zone is Alliance-specific.

Example

assert(tourist:IsAlliance("Elwynn Forest"))

 :IsHorde("zone")

Returns whether the given zone is Horde-specific.

Args

"zone" 
string - zone to check

Returns

boolean - whether the given zone is Horde-specific.

Example

assert(tourist:IsHorde("Durotar"))

 :IsFriendly("zone")

Returns whether the given zone is friendly.

Args

"zone" 
string - zone to check

Returns

boolean - whether the given zone is friendly.

Remarks

This is the same as :IsAlliance("zone") if you are Alliance or :IsHorde("zone") if you are Horde.

Example

assert(tourist:IsFriendly("The Barrens")) -- if Horde

 :IsHostile("zone")

Returns whether the given zone is hostile.

Args

"zone" 
string - zone to check

Returns

boolean - whether the given zone is hostile.

Remarks

This is the same as :IsAlliance("zone") if you are Horde or :IsHorde("zone") if you are Alliance.

Example

assert(tourist:IsHostile("Deadmines")) -- if Horde

 :IsContested("zone")

Returns whether the given zone is neither Horde nor Alliance specific.

Args

"zone" 
string - zone to check

Returns

boolean - whether the given zone is hostile.

Example

assert(tourist:IsHostile("Ashenvale"))

 :IsInKalimdor("zone")

Returns whether the given zone or instance is in Kalimdor.

Args

"zone" 
string - zone to check

Returns

boolean - whether the given zone or instance is in Kalimdor.

Example

assert(tourist:IsInKalimdor("Ashenvale"))

 :IsInEasternKingdoms("zone")

Returns whether the given zone or instance is in the Eastern Kingdoms.

Args

"zone" 
string - zone to check

Returns

boolean - whether the given zone or instance is in the Eastern Kingdoms.

Example

assert(tourist:IsInEasternKingdoms("Tirisfal Glades"))

 :IsInOutland("zone")

Returns whether the given zone or instance is in Outland.

Args

"zone" 
string - zone to check

Returns

boolean - whether the given zone or instance is in Outland.

Remarks

Only works if you have The Burning Crusade installed.

Example

assert(tourist:IsInOutland("Hellfire Citadel"))

 :GetInstanceGroupSize("instance")

Returns the group size of the given instance.

Args

"instance" 
string - instance to check

Returns

number - the size of the group you can take into the given instance.

Remarks

If the instance is not found or the group size of the instance is unknown, 0 will be returned.

For battlegrounds, this corresponds to the size one side can have.

Example

assert(tourist:GetInstanceGroupSize("Ragefire Chasm") == 5)

 :IterateBorderZones("zone")

Returns an iterator to traverse the zones bordering the given zone.

Args

"zone" 
string - zone or instance to check

Returns

iterator - an iterator to traverse the zones bordering the given zone.

Remarks

This will return a blank iterator if the given zone is not a real zone.

This will return instances inside the zone, or if an instance is given, the zone containing the instance.

This may return the names of boats or zeppelins.

Example

for zone in tourist:IterateBorderZones("Tirisfal Glades") do
    print(zone)
end

 :IteratePath("alpha", "bravo")

Returns an iterator to traverse the best path between two given zones.

Args

"alpha" 
string - zone or instance to start at.
"bravo" 
string - zone or instance to finish at.

Returns

iterator - an iterator to traverse the best path between two given zones.

Remarks

This will return a blank iterator if either given zone is not a real zone.

This may return the names of boats or zeppelins.

This finds the best path using Dijkstra's algorithm, with weighted edges based on the player's level relative to the zone, and whether the zone is friendly or not.

Example

for zone in tourist:IteratePath("Mulgore", "Tirisfal Glades") do
    print(zone)
end

 :GetZoneYardSize("zone")

Returns the width and height in yards of a given zone.

Args

"zone" 
string - zone to check

Returns

width, height

width 
number - width in yards
nil - zone not found or unknown size
height 
number - height in yards
nil - zone not found or unknown size

Example

local width, height = tourist:GetZoneYardSize("Mulgore")

 :GetTexture("zone")

Returns the name of the texture based on the zone.

Args

"zone" 
string - zone to check

Remarks

The texture is determined by GetMapInfo()

Returns

"texture"
string - name of the texture
nil - zone not found or Azeroth

 :GetZoneFromTexture(["texture"])

Returns the name of the zone based on the texture.

Args

"texture" 
string - texture
nil - Azeroth

Returns

"zone"
string - name of the zone
nil - unknown texture

 :GetEnglishZoneFromTexture(["texture"])

Returns the English name of the zone based on the texture.

Args

"texture" 
string - texture
nil - Azeroth

Returns

"zone"
string - English name of the zone
nil - unknown texture

 :TransposeZoneCoordinate(x, y, "fromZone", "toZone")

Transposes the coordinates of one zone to what they would be on another zone.

Args

number - horizontal coordinate
number - vertical coordinate
"fromZone" 
string - the zone the x, y coordinates are currently on
"toZone" 
string - the zone you wish to transpose onto.

Returns

x, y

number - horizontal coordinate
nil - cannot transpose properly.
number - vertical coordinate
nil - cannot transpose properly.

 :GetBestZoneCoordinate(x, y, "zone")

Return a better zone for the given coordinate if it is found.

Args

number - horizontal coordinate
number - vertical coordinate
"zone" 
string - the zone the x, y coordinates are currently on

Returns

x, y, "zone"

number - new horizontal coordinate
number - new vertical coordinate
"zone" 
string - the new zone which the x, y coordinates are now on.