@ -88,7 +88,7 @@ dbot.version : Module to track version and changelog information and update the
save_state="y"
save_state="y"
date_written="2017-08-12 08:45:15"
date_written="2017-08-12 08:45:15"
requires="4.98"
requires="4.98"
version="2.0024 "
version="2.0025 "
>
>
<description trim= "y" >
<description trim= "y" >
< ![CDATA[
< ![CDATA[
@ -4310,31 +4310,34 @@ as "@Cmana@W" and "@Cheal@W" include multiple instances for different levels. T
become important later on in this walk-through.
become important later on in this walk-through.
"@Gdinv consume display@W"
"@Gdinv consume display@W"
@WDINV Consumable Type "move"
@Cfly @W Level Room # Avail Name
@W Level 90 (@CRoom 23160@W) "@Gmoonshine@W"
@w 1 32476 @M 3@w griff
@WDINV Consumable Type "mana"
@w
@W Level 1 (@CRoom 32476@W) "@Glotus rush@W"
@Cheal @W Level Room # Avail Name
@W Level 20 (@CRoom 30525@W) "@Gnachos@W"
@w 1 32476 0 light relief
@W Level 30 (@CRoom 14141@W) "@Glotus seed@W"
@w 20 32476 0 serious relief
@W Level 50 (@CRoom 23160@W) "@Gtequila@W"
@w 30 14141 0 minor healing
@W Level 60 (@CRoom 14141@W) "@Glotus stem@W"
@w 60 14141 0 seekers60heal
@W Level 81 (@CRoom 47106@W) "@Gwaterspirit@W"
@w 201 50209 @M 136@w frank
@W Level 91 (@CRoom 49373@W) "@Gblood@W"
@w
@W Level 100 (@CRoom 14141@W) "@Glotus bud@W"
@Cmana @W Level Room # Avail Name
@W Level 130 (@CRoom 30525@W) "@Gpopcorn@W"
@w 1 32476 0 lotus rush
@W Level 150 (@CRoom 14141@W) "@Glotus bloom@W"
@w 20 30525 0 nachos
@W Level 200 (@CRoom 23160@W) "@Gdaniel@W"
@w 30 14141 0 lotus seed
@W Level 201 (@CRoom 14141@W) "@Glotus flower@W"
@w 50 23160 0 tequila
@WDINV Consumable Type "sight"
@w 60 14141 0 lotus stem
@W Level 1 (@CRoom 32476@W) "@Gwolf@W"
@w 85 28359 0 alabaster
@WDINV Consumable Type "heal"
@w 100 14141 0 lotus bud
@W Level 1 (@CRoom 32476@W) "@Glight relief@W"
@w 130 30525 0 popcorn
@W Level 20 (@CRoom 32476@W) "@Gserious relief@W"
@w 150 14141 0 lotus bloom
@W Level 30 (@CRoom 14141@W) "@Gminor healing@W"
@w 175 28359 0 diamond
@W Level 60 (@CRoom 14141@W) "@Gseekers60heal@W"
@w 201 14141 @M 154@w lotus flower
@W Level 201 (@CRoom 50209@W) "@Gfrank@W"
@w
@WDINV Consumable Type "fly"
@Cmove @W Level Room # Avail Name
@W Level 1 (@CRoom 32476@W) "@Ggriff@W"@W
@w 90 23160 @M 2@w moonshine
@w
@Csight @W Level Room # Avail Name
@w 1 32476 0 wolf
Now we want to buy one item of type "@Cheal@W". Note that this doesn't necessarily
Now we want to buy one item of type "@Cheal@W". Note that this doesn't necessarily
mean that it has the "heal" spell. It could be any type of potion or pill that
mean that it has the "heal" spell. It could be any type of potion or pill that
@ -7989,7 +7992,7 @@ function inv.items.displayCR()
-- Let the user know if no items matched their query
-- Let the user know if no items matched their query
elseif (idArray == nil) or (#idArray == 0) then
elseif (idArray == nil) or (#idArray == 0) then
dbot.info("No items matched query: \"" .. inv.items.displayPkg.queryString .. " \"")
dbot.info("@Y0@W items matched query \"@c" .. inv.items.displayPkg.queryString .. "@W \"")
else
else
-- Sort and display the results
-- Sort and display the results
@ -7998,6 +8001,14 @@ function inv.items.displayCR()
for _, objId in ipairs(idArray) do
for _, objId in ipairs(idArray) do
inv.items.displayItem(objId, inv.items.displayPkg.verbosity)
inv.items.displayItem(objId, inv.items.displayPkg.verbosity)
end -- for
end -- for
local suffix = "s"
if (#idArray == 1) then
suffix = ""
end -- if
print("")
dbot.info("@Y" .. #idArray .. "@W item" .. suffix .. " matched query \"@c" ..
inv.items.displayPkg.queryString .. "@W\"")
end -- if
end -- if
inv.items.displayPkg = nil
inv.items.displayPkg = nil
@ -16732,7 +16743,13 @@ function inv.consume.display(typeName)
if (typeName ~= nil) and (typeName ~= "") then
if (typeName ~= nil) and (typeName ~= "") then
numEntries = inv.consume.displayType(typeName)
numEntries = inv.consume.displayType(typeName)
else
else
local sortedTypes = {}
for itemType,_ in pairs(inv.consume.table) do
for itemType,_ in pairs(inv.consume.table) do
table.insert(sortedTypes, itemType)
end -- for
table.sort(sortedTypes, function (v1, v2) return v1 < v2 e n d )
for _, itemType in ipairs(sortedTypes) do
numEntries = numEntries + inv.consume.displayType(itemType)
numEntries = numEntries + inv.consume.displayType(itemType)
end -- for
end -- for
end -- if
end -- if
@ -16756,12 +16773,27 @@ function inv.consume.displayType(typeName)
return numEntries, DRL_RET_MISSING_ENTRY
return numEntries, DRL_RET_MISSING_ENTRY
end -- if
end -- if
dbot.print("@W" .. pluginNameAbbr .. " Consumable Type \"" .. typeName .. "\"@w" )
dbot.print(string.format("\n@W@C%-10s@W Level Room # Avail Name", (typeName or "nil")) )
if (inv.consume.table[typeName] ~= nil) then
if (inv.consume.table[typeName] ~= nil) then
for _, entry in ipairs(inv.consume.table[typeName]) do
for _, entry in ipairs(inv.consume.table[typeName]) do
dbot.print("@W Level " .. string.format("%3d", (entry.level or "")) ..
local count = 0
" (@CRoom " .. string.format("%3d", (entry.room or 0)) .. "@W)" ..
" \"@G" .. (entry.name or "") .. "@W\"@w")
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
end -- if
end -- for
local countColor = ""
if (count > 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
numEntries = numEntries + 1
end -- for
end -- for
end -- if
end -- if
@ -16916,30 +16948,49 @@ function inv.consume.get(typeName, size, containerId)
if (entry.level < = curLevel) then
if (entry.level < = curLevel) then
-- If we have one of these items available, return the ID for it. Otherwise, try the next entry
-- If we have one of these items available, return the ID for it. Otherwise, try the next entry
-- in the consumable table
-- in the consumable table
local objInContainerId = nil
local finalId = nil
local finalId = nil
local preferredId = nil
local count = 0
for objId, itemEntry in pairs(inv.items.table) do
for objId, itemEntry in pairs(inv.items.table) do
local itemLevel = tonumber(inv.items.getStatField(objId, invStatFieldLevel) or "")
local itemLevel = tonumber(inv.items.getStatField(objId, invStatFieldLevel) or "")
local itemName = inv.items.getStatField(objId, invStatFieldName) or ""
local itemName = inv.items.getStatField(objId, invStatFieldName) or ""
if (entry.level == itemLevel) and (entry.fullName == itemName) then
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
-- 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
-- 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
-- preferred location, break immediately and use it. Otherwise, remember the item and keep
-- searching for something at the preferred location.
-- searching for something at the preferred location.
if (preferredId == nil) and (inv.items.getField(objId, invFieldObjLoc) == preferredLocation) then
preferredId = objId
else
finalId = objId
finalId = objId
if (inv.items.getField(objId, invFieldObjLoc) == preferredLocation) then
break
end -- if
end -- if
end -- if
end -- if
end -- for
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 we found a matching item instance, return it!
if (finalId ~= nil) then
if (finalId ~= nil) then
dbot.note("@WFound \"@C" .. typeName .. "@W\"@G L" .. entry.level .. " @W\"@Y" ..
dbot.info("(" .. countColor .. count .. " available@W) " ..
(inv.items.getStatField(finalId, invStatFieldName) or "") ..
"Consuming L" .. entry.level .. " \"@C" .. typeName .. "@W\" @Y" ..
"@W\" @@ \"@R" .. (inv.items.getField(finalId, invFieldObjLoc) or "") .. "@W\"")
(inv.items.getStatField(finalId, invStatFieldName) or "") .. "@W")
return finalId, DRL_RET_SUCCESS
return finalId, DRL_RET_SUCCESS
end -- if
end -- if