Exemplo n.º 1
0
        //API doesn't currently support custom pet food - this is a workaround
        public void Feed(String food)
        {
            string luaCheckFeed = "CanFeedMyPet = 0; if CursorHasSpell() then CanFeedMyPet = 1 end;";
            string luaFeedPet   = "CastSpellByName('Feed Pet'); TargetUnit('Pet');";
            string UsePetFood1  = "for bag = 0,4 do for slot = 1,GetContainerNumSlots(bag) do local item = GetContainerItemLink(bag,slot) if item then if string.find(item, '";
            string UsePetFood2  = "') then PickupContainerItem(bag,slot) break end end end end";

            if (!Pet.GotBuff("Feed Pet Effect"))
            {
                if (Player.ItemCount(food) != 0)
                {
                    Player.DoString(luaCheckFeed);
                    if (Player.GetText("CanFeedMyPet").Trim().Contains("0"))
                    {
                        Player.DoString(luaFeedPet);
                    }
                    Player.DoString(UsePetFood1 + food.Replace("'", "\\'") + UsePetFood2);
                }
            }
            Player.DoString("ClearCursor()");
        }