View Single Post
11/18/14, 09:15 PM   #4
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
I'm pretty sure the keys in the slots table matches the slotIndices. So you could loop through the slots and check to see if each key exists in the table.

Lua Code:
  1. local inventory = PLAYER_INVENTORY.inventories[INVENTORY_BACKPACK].slots
  2. local bagSize = GetBagSize(BAG_BACKPACK)
  3.    
  4. for i = 0, bagSize-1 do
  5.    if not inventory[i] then
  6.       -- do whatever inventory[i] is an empty slot
  7.    end
  8. end

Or you could make it into a function and each time you find an empty slot throw it into a table, then return the table & you'll have all of the empty slots to do whatever you want with them.

Although merlights answer is probably better for what your doing, just giving some options.
  Reply With Quote