From 000a5352ca68ad626944330180dd59ddbdadab1f Mon Sep 17 00:00:00 2001 From: Durel Date: Tue, 31 Oct 2017 12:02:47 -0400 Subject: [PATCH] 1) Added support for searching for items with particular spells. For example, use "dinv search spells lotus" to match black lotus potions or pills or use "dinv search spells heal" for healing potions or pills. --- aard_inventory.xml | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/aard_inventory.xml b/aard_inventory.xml index 5e1ee86..7e9144a 100644 --- a/aard_inventory.xml +++ b/aard_inventory.xml @@ -1921,10 +1921,13 @@ Examples: @W 1@w @RAardWords (TM)@Y - [P] - S @Whold 0 0 0 0 0 0 0 0 0 0 0 0 @W 1@w @RAardWords (TM)@Y - [W] - S @Whold 0 0 0 0 0 0 0 0 0 0 0 0 - 7) Display your items that are equipped + 7) Find armor that is enchantable + "@Gdinv search type armor flag invis || type armor ~flag hum || type armor ~flag glow@W" + + 8) Display your items that are equipped "@Gdinv search worn@W" - 8) Display EVERYTHING (no I'm not pasting that output here!) + 9) Display EVERYTHING (no I'm not pasting that output here!) "@Gdinv search all@W" ]]) @@ -7495,10 +7498,26 @@ function inv.items.search(arrayOfQueryArrays) break end -- if + -- Handle a "spells" name search. The spells are in a table so we need to handle + -- this a little differently than normal so that we can unpack the table. + elseif (key == invStatFieldSpells) and (type(statsVal) == "table") then + local foundSpell = false + for _,spellEntry in ipairs(statsVal) do + if dbot.isWordInString(string.lower(value), spellEntry.name) then + foundSpell = true + break + end -- if + end -- for + + if (foundSpell and (invert == true)) or ((not foundSpell) and (invert == false)) then + itemMatches = false + break + end -- if + -- Handle a basic string query (use lowercase only to make queries a bit simpler) - elseif ((invert == false) and (prefix == nil) and + elseif ((invert == false) and (prefix == nil) and (type(statsVal) ~= "table") and (string.lower(statsVal) ~= string.lower(value))) or - ((invert == true) and (prefix == nil) and + ((invert == true) and (prefix == nil) and (type(statsVal) ~= "table") and (string.lower(statsVal) == string.lower(value))) then itemMatches = false break