WoW API: GetPetFoodTypes

Revision as of 08:36, 30 January 2007 by WoWWiki>Sarf (→‎Example)

WoW API < GetPetFoodTypes

local PetFoodList = {GetPetFoodTypes()};

Returns

Returns a list with strings.

Possible strings

  • Meat
  • Fish
  • Fruit
  • Fungus
  • Bread
  • Cheese

Example

To print every string from the list into the default chatframe.

local PetFoodList = GetPetFoodTypes();
if ( type(PetFoodList) == "table" ) and ( getn(PetFoodList) > 0 ) then
    local index, foodType;
    for index, foodType in pairs(PetFoodList) do
        DEFAULT_CHAT_FRAME:AddMessage(foodType);
    end
else
    DEFAULT_CHAT_FRAME:AddMessage("No pet food types available.");
end

Updated script with for loop using pairs and "better" code.