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.

[All] ItemsManager.GetItemCountByNameLua is incorrect

  • Version: All
  • Product: WRobot General
  • Type: Bug
  • Status: Confirmed

Currently this function first uses GetItemInfo("name") to get the itemId then searches in bags for the ID.
There are several items with different IDs but the same name (for example, Healthstone).

This function works:

public static int GetItemCount(string itemName)
    {
        string countLua =
        $@"
        local fullCount = 0;
        for bag=0,4 do
            for slot=1,36 do
                local name = GetContainerItemLink(bag, slot);
                if (name and name == ""{itemName}"") then
                    local texture, count = GetContaimerItemInfo(bag, slot);
                    fullCount = fullCount + count;
                end;
            end;
        end
        return fullCount;";
        return Lua.LuaDoString<int>(countLua);
    }

 

User Feedback

Recommended Comments

Matenia

Elite user

Can't edit original report, but function is also a bit wrong - this works in vanilla/tbc/wrath:
 

public static int GetItemCount(string itemName)
    {
        string countLua =
        $@"
        local fullCount = 0;
        for bag=0,4 do
            for slot=1,36 do
                local itemLink = GetContainerItemLink(bag, slot);
                if (itemLink) then
                    local itemString = string.match(itemLink, ""item[%-?%d:]+"");
                    if(GetItemInfo(itemString) == ""{itemName}"") then
                        local texture, count = GetContaimerItemInfo(bag, slot);
                        fullCount = fullCount + count;
                    end
                end;
            end;
        end
        return fullCount;";
        return Lua.LuaDoString<int>(countLua);
    }

 

Hello, you get problem with "GetItemCountByNameLUA"? You get problem only on Lua or with tbc and wotlk also?

Matenia

Elite user

I get it with GetItemCountByNameLUA and on vanilla + tbc. But I noticed on TBC.

Matenia

Elite user

I forgot string.match is not in vanilla, this works across vanilla-wotlk:

public static int GetItemCount(string itemName)
    {
        string countLua =
            $@"
        local fullCount = 0;
        for bag=0,4 do
            for slot=1,36 do
                local itemLink = GetContainerItemLink(bag, slot);
                if (itemLink) then
                    local _,_, itemId = string.find(itemLink, 'item:(%d+):');
                    if (GetItemInfo(itemId) == ""{itemName}"") then
                        local texture, count = GetContainerItemInfo(bag, slot);
                        fullCount = fullCount + count;
                    end
                end
            end
        end
        return fullCount;";
        return Lua.LuaDoString<int>(countLua);
    }

 

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.