Skip to content
View in the app

A better way to browse. Learn more.

WRobot

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Bag.GetBagItem()

Featured Replies

  • 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"

21,10,17(13-36-23).jpg

21,10,17(13-36-31).jpg

foreach (var woWItem in wManager.Wow.Helpers.Bag.GetBagItem())
{
	uint temp = wManager.Wow.Helpers.ItemsManager.GetIdByName(woWItem.Name); //Item ID						
}

 

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?

@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:

 

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);

 

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");

 

  • 1 year later...

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!

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:
image.png.555caa81fbeabd1dfb812710cbf6acf1.png

Or you can start wrobot and use Tool/Development Tool:
image.png.e4ace6dc9b869dafa74ef03c5bb8007f.png

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.

12 hours ago, Findeh said:

You can use wowhead:
image.png.555caa81fbeabd1dfb812710cbf6acf1.png

Or you can start wrobot and use Tool/Development Tool:
image.png.e4ace6dc9b869dafa74ef03c5bb8007f.png

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.