+ Reply to Thread
Results 1 to 4 of 4

Thread: Counting items in invetory

  1. #1
    Shadowlander Hecateria's Avatar
    Join Date
    Apr 2012
    Posts
    44

    Default Counting items in invetory

    it probebly is something realy simple, but i cant seen to find out how to do it.

    This is what i want, count the amount of items in my inventory of a specific type of item.

    i tryed this but that gave error: incorrect function usage
    Code:
    function getItemCount(ItemID)
        local Count = 0
        local ItemsInInv = Inspect.Item.List(ItemID)
        for _ in pairs(ItemsInInv) do Count = Count + 1 end
        return Count
    end
    
    local SearchItemID = clipboard.type
    local TotalItemsFound = getItemCount(SearchItemID)
    print("Total items in your inventory of this type: " .. TotalItemsFound)
    Hope someone can tell me what i do wrong here

    Greetings and already thanks Heca

  2. #2
    RIFT Community Ambassador the_real_seebs's Avatar
    Join Date
    Jan 2011
    Posts
    16,859

    Default

    Inspect.Item.List does not list items by type, it lists items matching a given partial slot specifier. So, say:

    Inspect.Item.List(Utility.Item.Slot.Vault())

    You'd have to grab all the items and check their types yourself to do what you want. Note that LibBaggotry already provides an interface for this.
    You can play WoW in any MMO. You don't have to play WoW in RIFT. Oh, and no, RIFT is not a WoW clone. Not having fun any more? Learn to play, noob! I don't speak for Riftui, but I moderate stuff there. Just came back? Welcome back! Here's what's changed. (Updated for 2.5!)

  3. #3
    Telaran
    Join Date
    Dec 2013
    Posts
    60

    Default

    in game calculator would be more adequate, just subtract empty bag slots from inventory
    Last edited by Quackfosh1; 12-15-2013 at 08:54 PM.

  4. #4
    RIFT Fan Site Operator Hewi's Avatar
    Join Date
    Mar 2012
    Posts
    410

    Default

    there's probably a nicer way of formatting this, but this works for me...

    Code:
    say you're looking for artifacts - where the type is "misc collectible", usage would be the following:
    
    print("Searching for artifacts...")
    print("Found: " .. getItemCount("misc collectible"))
    
    -- This function allows for a variable number of bags, rather than assuming you have 7 and looping through them all.
    
    function getItemCount(itemType)
    	local count = 0
    	
    	local allBags = Utility.Item.Slot.Inventory("bag")
    	local allBagsDetail = Inspect.Item.Detail(allBags)
    	
    	for i = 1, tablelength(allBagsDetail), 1 do
    		bagSlot = Utility.Item.Slot.Inventory(i)
    		bagItems = Inspect.Item.List(bagSlot)
    		for key, value in pairs(bagItems) do
    			if value ~= false then -- Slot isn't empty
    				itemDetail = Inspect.Item.Detail(value)
    				if itemDetail["category"] == itemType then
    					count = count + tonumber(itemDetail["stack"])
    				end
    			end
    		end
    	end
    	
    	return count
    end
    
    function tablelength(T)
      local count = 0
      for _ in pairs(T) do count = count + 1 end
      return count
    end
    Last edited by Hewi; 12-29-2013 at 07:46 AM.

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts