1) Fixed potential nil access when using "dinv weapon next" for an unidentified weapon

2) Added "dinv usage allUsed [query]" mode to show usage of only items that are actually
   used by at least one analyzed priority (priorities w/o an analysis aren't included)
master
Durel 7 years ago
parent 9b6d8740f3
commit 1065f798dc

@ -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.0027" version="2.0028"
> >
<description trim="y"> <description trim="y">
<![CDATA[ <![CDATA[
@ -142,7 +142,7 @@ Usage
Equipment analysis Equipment analysis
dinv analyze [list | create | delete | display] <priority name> <positions> dinv analyze [list | create | delete | display] <priority name> <positions>
dinv usage <priority name | all> <query> dinv usage <priority name | all | allUsed> <query>
dinv compare <priority name> <relative name> dinv compare <priority name> <relative name>
dinv covet <priority name> <auction #> dinv covet <priority name> <auction #>
@ -357,7 +357,7 @@ Feature Wishlist
<alias <alias
script="inv.cli.usage.fn" script="inv.cli.usage.fn"
match="^[ ]*dinv[ ]+usage[ ]+(all|[^ ]+)[ ]*(.*?)?$" match="^[ ]*dinv[ ]+usage[ ]+(allUsed|all|[^ ]+)[ ]*(.*?)?$"
enabled="y" enabled="y"
expand_variables="y" expand_variables="y"
regexp="y" regexp="y"
@ -3265,7 +3265,7 @@ end -- inv.cli.usage.fn
function inv.cli.usage.usage() function inv.cli.usage.usage()
dbot.print("@W " .. pluginNameCmd .. " usage @G<priority name | all> <query>@w") dbot.print("@W " .. pluginNameCmd .. " usage @G<priority name | all | allUsed> <query>@w")
end -- inv.cli.usage.usage end -- inv.cli.usage.usage
@ -3342,9 +3342,9 @@ Examples:
@R100@W a protective cloak skinned from @G(1695078138) @YArmor@W psi-melee @RUnused @R100@W a protective cloak skinned from @G(1695078138) @YArmor@W psi-melee @RUnused
@G100@W a protective cloak skinned from @G(1672257124) @YArmor@W psi-melee @G100-170@W @G100@W a protective cloak skinned from @G(1672257124) @YArmor@W psi-melee @G100-170@W
3) You can even use the empty search string to find the usage for all of your items. I'm 3) You can even use the "all" search string to find the usage for all of your items. I'm
not copying that output into this helpfile though :) not copying that output into this helpfile though :)
"@Gdinv usage psi-melee@W" "@Gdinv usage psi-melee all@W"
]]) ]])
end -- inv.cli.usage.examples end -- inv.cli.usage.examples
@ -14821,6 +14821,11 @@ function inv.weapon.next(endTag)
return inv.tags.stop(invTagsSet, endTag, DRL_RET_MISSING_ENTRY) return inv.tags.stop(invTagsSet, endTag, DRL_RET_MISSING_ENTRY)
end -- if end -- if
if (currentDamType == nil) then
dbot.info("Skipping next weapon request: Unknown damage type -- You may need an inventory refresh")
return inv.tags.stop(invTagsSet, endTag, DRL_RET_UNINITIALIZED)
end -- if
dbot.debug("inv.weapon.next: Current dam type is: \"" .. currentDamType .. "\"") dbot.debug("inv.weapon.next: Current dam type is: \"" .. currentDamType .. "\"")
-- Remove the current primary dam type for each priority block in the weapon set priority -- Remove the current primary dam type for each priority block in the weapon set priority
@ -16075,7 +16080,7 @@ end -- inv.analyze.display
-- --
-- inv.usage.display(priorityName, query, endTag) -- inv.usage.display(priorityName, query, endTag)
-- inv.usage.displayCR() -- inv.usage.displayCR()
-- inv.usage.displayItem(priorityName, objId) -- inv.usage.displayItem(priorityName, objId, doDisplayUnused)
-- inv.usage.get(priorityName, objId) -- inv.usage.get(priorityName, objId)
-- --
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
@ -16151,10 +16156,14 @@ function inv.usage.displayCR()
if (priorityName == "all") then if (priorityName == "all") then
for priority, _ in pairs(inv.priority.table) do for priority, _ in pairs(inv.priority.table) do
inv.usage.displayItem(priority, id) inv.usage.displayItem(priority, id, true)
end -- for
elseif (priorityName == "allUsed") then
for priority, _ in pairs(inv.priority.table) do
inv.usage.displayItem(priority, id, false)
end -- for end -- for
else else
inv.usage.displayItem(priorityName, id) inv.usage.displayItem(priorityName, id, true)
end -- if end -- if
end -- if end -- if
end -- for end -- for
@ -16167,9 +16176,9 @@ function inv.usage.displayCR()
end -- inv.usage.displayCR end -- inv.usage.displayCR
function inv.usage.displayItem(priorityName, objId) function inv.usage.displayItem(priorityName, objId, doDisplayUnused)
-- TODO: this is very similar to code in displayItem: consolidate it into a helper function -- TODO: this is very similar to code in inv.items.displayItem: consolidate it into a helper function
local colorName = inv.items.getField(objId, invFieldColorName) or "Unknown" local colorName = inv.items.getField(objId, invFieldColorName) or "Unknown"
local maxNameLen = 44 local maxNameLen = 44
@ -16257,8 +16266,11 @@ function inv.usage.displayItem(priorityName, objId)
end -- for end -- for
end -- if end -- if
-- Display the result for this item/priority if it is used or if the user wants to display unused items
if ((levelUsage ~= nil) and (#levelUsage > 0)) or doDisplayUnused then
dbot.print(string.format("%s%3d%s " .. formattedName .. itemType .. " " .. priorityName .. dbot.print(string.format("%s%3d%s " .. formattedName .. itemType .. " " .. priorityName ..
" " .. levelStr, levelPrefix, itemLevel, levelSuffix)) " " .. levelStr, levelPrefix, itemLevel, levelSuffix))
end -- if
end -- inv.usage.displayItem end -- inv.usage.displayItem

Loading…
Cancel
Save