diff --git a/aard_inventory.xml b/aard_inventory.xml index db50ff7..9c9700f 100644 --- a/aard_inventory.xml +++ b/aard_inventory.xml @@ -88,7 +88,7 @@ dbot.version : Module to track version and changelog information and update the save_state="y" date_written="2017-08-12 08:45:15" requires="4.98" - version="2.0024" + version="2.0025" > 0) then + countColor = "@M" + end -- if + + dbot.print(string.format(" %3d %5d %s%4d@w %s", + (entry.level or 0), (entry.room or 0), countColor, count, (entry.name or "nil"))) numEntries = numEntries + 1 end -- for end -- if @@ -16916,30 +16948,49 @@ function inv.consume.get(typeName, size, containerId) if (entry.level <= curLevel) then -- If we have one of these items available, return the ID for it. Otherwise, try the next entry -- in the consumable table - local objInContainerId = nil local finalId = nil + local preferredId = nil + local count = 0 for objId, itemEntry in pairs(inv.items.table) do local itemLevel = tonumber(inv.items.getStatField(objId, invStatFieldLevel) or "") local itemName = inv.items.getStatField(objId, invStatFieldName) or "" if (entry.level == itemLevel) and (entry.fullName == itemName) then + count = count + 1 + -- We try to use items from the preferred location first (e.g., a user-specified container or -- the main inventory if no container is specified). If we find an item instance at the -- preferred location, break immediately and use it. Otherwise, remember the item and keep -- searching for something at the preferred location. - finalId = objId - if (inv.items.getField(objId, invFieldObjLoc) == preferredLocation) then - break + if (preferredId == nil) and (inv.items.getField(objId, invFieldObjLoc) == preferredLocation) then + preferredId = objId + else + finalId = objId end -- if end -- if end -- for + if (preferredId ~= nil) then + finalId = preferredId + end -- if + + local countColor + if (count > 50) then + countColor = "@G" + elseif (count > 20) then + countColor = "@Y" + else + countColor = "@R" + end -- if + -- If we found a matching item instance, return it! if (finalId ~= nil) then - dbot.note("@WFound \"@C" .. typeName .. "@W\"@G L" .. entry.level .. " @W\"@Y" .. - (inv.items.getStatField(finalId, invStatFieldName) or "") .. - "@W\" @@ \"@R" .. (inv.items.getField(finalId, invFieldObjLoc) or "") .. "@W\"") + dbot.info("(" .. countColor .. count .. " available@W) " .. + "Consuming L" .. entry.level .. " \"@C" .. typeName .. "@W\" @Y" .. + (inv.items.getStatField(finalId, invStatFieldName) or "") .. "@W") + + return finalId, DRL_RET_SUCCESS end -- if