October 21, 20178 yr "wManager.Wow.Helpers.Bag.GetBagItem()" - not return itemtype "Container" in bags :(
October 21, 20178 yr Author 35 minutes ago, Droidz said: Hello, do you use wow addons? if yes try to disable all No one addon. In DevelopmentTools if click :"bag items list" - also empty for itemtype "Container"
October 21, 20178 yr foreach (var woWItem in wManager.Wow.Helpers.Bag.GetBagItem()) { uint temp = wManager.Wow.Helpers.ItemsManager.GetIdByName(woWItem.Name); //Item ID }
October 21, 20178 yr To add another question onto this, Bag.GetBagItem() only shows 1 instance of the item, even if there are more of them in different bags, anyway to get the containerid/slot for each?
October 21, 20178 yr @Marsbar Hello, i've written a method for this: public struct BagInfo { public int Bag; public int Slot; public BagInfo(int bag, int slot) { Bag = bag; Slot = slot; } public override string ToString() { return "Bag = " + Bag + " ; Slot = " + Slot; } } /// <summary> /// Used to get a list of locations of the item as bag and slot position. /// </summary> /// <param name="itemName">The item name to search.</param> /// <returns></returns> public static List<BagInfo> GetItemLocations(string itemName) { var execute = "local bs = {}" + "for b=0,4 do " + "if GetBagName(b) then " + "for s=1, GetContainerNumSlots(b) do " + "local itemLink = GetContainerItemLink(b, s) " + "if itemLink then " + "local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture, itemSellPrice = GetItemInfo(itemLink) \t" + "if itemName == '"+itemName+"' "; execute += "then " + "table.insert(bs, b); " + "table.insert(bs, s); " + "\tend\tend\tend end end return unpack(bs);"; var bs = Lua.LuaDoString<List<int>>(execute); var list = new List<BagInfo>(); for (var i = 0; i < bs.Count; i += 2) list.Add(new BagInfo(bs[i], bs[i+1])); return list; } Usage: GetItemLocations("Mutton Chop").ForEach(i => Logging.Write(i.ToString())); Here are also other similar methods to interact with items:
October 22, 20178 yr @reapler Sadly not working for me. Getting a Index was out of range error. I'm doing this for soul shard management, wanting to delete all soul shards exepct for a certain amount.
October 22, 20178 yr 2 hours ago, Marsbar said: @reapler Sadly not working for me. Getting a Index was out of range error. I'm doing this for soul shard management, wanting to delete all soul shards exepct for a certain amount. Not fully tested, but this should work: /// <summary> /// Used to get the item quantity by name. /// </summary> /// <param name="itemName">The item name.</param> /// <remarks>Replacement for GetItemCount in vanilla.</remarks> /// <returns></returns> public static int GetItemQuantity(string itemName) { var execute = "local itemCount = 0; " + "for b=0,4 do " + "if GetBagName(b) then " + "for s=1, GetContainerNumSlots(b) do " + "local itemLink = GetContainerItemLink(b, s) " + "if itemLink then " + "local _, stackCount = GetContainerItemInfo(b, s)\t " + "if string.find(itemLink, \"" + itemName + "\") then " + "itemCount = itemCount + stackCount; " + "end " + "end " + "end " + "end " + "end; " + "return itemCount; "; return Lua.LuaDoString<int>(execute); } /// <summary> /// Used to delete all items by name. /// </summary> /// <param name="itemName">The item to delete.</param> /// <param name="leaveAmount">The amount of items which remain in the bag.</param> /// <remarks>Bug at links with "-"</remarks> public static void DeleteItems(string itemName, int leaveAmount) { var itemQuantity = GetItemQuantity(itemName) - leaveAmount; if (string.IsNullOrWhiteSpace(itemName) || itemQuantity <= 0) return; var execute = "local itemCount = "+itemQuantity+"; " + "local deleted = 0; " + "for b=0,4 do " + "if GetBagName(b) then " + "for s=1, GetContainerNumSlots(b) do " + "local itemLink = GetContainerItemLink(b, s) " + "if itemLink then " + "local _, stackCount = GetContainerItemInfo(b, s)\t " + "local leftItems = itemCount - deleted; " + "if string.find(itemLink, \""+ itemName + "\") and leftItems > 0 then " + "if stackCount <= 1 then " + "PickupContainerItem(b, s); " + "DeleteCursorItem(); " + "deleted = deleted + 1; " + "else " + "if (leftItems > stackCount) then " + "SplitContainerItem(b, s, stackCount); " + "DeleteCursorItem(); " + "deleted = deleted + stackCount; " + "else " + "SplitContainerItem(b, s, leftItems); " + "DeleteCursorItem(); " + "deleted = deleted + leftItems; " + "end " + "end " + "end " + "end " + "end " + "end " + "end; "; Lua.LuaDoString(execute); } Usage: DeleteItems("Soul Shard", 20);
October 22, 20178 yr 25 minutes ago, reapler said: Not fully tested, but this should work: Usage: DeleteItems("Soul Shard", 20); Works perfectly, thanks a lot!
October 25, 20178 yr 51 minutes ago, kpeno said: Maybe anyone have idea how convert item entry to wowitem ?:) Hello, you need to access the objectmanager to get your desired object: WoWItem item = ObjectManager.GetObjectWoWItem().FirstOrDefault(i => i.Entry == 1205);//Melon Juice Logging.Write(item?.Name ?? "Item not found");
August 17, 20196 yr hi all. i have no idea about the codes posted here. I was trying to search how to get my warlock create a spellstone then use it. i tried to base the "create healthstone" but I don't know how to get the itemID for the spellstone. if anyone can help me out that would be really great!
August 17, 20196 yr 3 hours ago, jiraiyasm said: hi all. i have no idea about the codes posted here. I was trying to search how to get my warlock create a spellstone then use it. i tried to base the "create healthstone" but I don't know how to get the itemID for the spellstone. if anyone can help me out that would be really great! You can use wowhead: Or you can start wrobot and use Tool/Development Tool: And then "Bag Items" or "Get all Objects" (if you have the spellstone already) or "Info by name". P.S. Don't use 41191 from my screenshot. It's most likely not a spellstone you are looking for.
August 18, 20196 yr 12 hours ago, Findeh said: You can use wowhead: Or you can start wrobot and use Tool/Development Tool: And then "Bag Items" or "Get all Objects" (if you have the spellstone already) or "Info by name". P.S. Don't use 41191 from my screenshot. It's most likely not a spellstone you are looking for. how can I set my warlock to use the master spellstone? Thank you.
Create an account or sign in to comment