|
|
|
@ -261,6 +261,7 @@ function print_help()
@@ -261,6 +261,7 @@ function print_help()
|
|
|
|
|
{ ' [<query>]', '- the word you are looking for.' }, |
|
|
|
|
{ ' [-d|--duplicates]', '- list only items which are found in more than one container.' }, |
|
|
|
|
{ ' [-e<filename>|--export=<filename>]', '- exports the results to a csv file in the data folder.' }, |
|
|
|
|
{ ' [-s|--stackables]', '- list only items which can stack.' }, |
|
|
|
|
} |
|
|
|
|
local examples = { |
|
|
|
|
{ '/findall thaumas', '- Search for "thaumas" on all your characters.' }, |
|
|
|
@ -315,6 +316,7 @@ function determine_query_elements(searchparams)
@@ -315,6 +316,7 @@ function determine_query_elements(searchparams)
|
|
|
|
|
local search_terms = {} |
|
|
|
|
local export = nil |
|
|
|
|
local duplicates = false |
|
|
|
|
local stackables = false |
|
|
|
|
|
|
|
|
|
for _, query_element in pairs(searchparams) do |
|
|
|
|
-- character specifiers must start with a '!' or a ':' |
|
|
|
@ -341,12 +343,14 @@ function determine_query_elements(searchparams)
@@ -341,12 +343,14 @@ function determine_query_elements(searchparams)
|
|
|
|
|
end |
|
|
|
|
elseif string.match(query_element, '^--duplicates$') or string.match(query_element, '^-d$') then |
|
|
|
|
duplicates = true |
|
|
|
|
elseif string.match(query_element, '^--stackables') or string.match(query_element, '^-s$') then |
|
|
|
|
stackables = true |
|
|
|
|
else |
|
|
|
|
table.insert(search_terms, query_element) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
return char_include, char_exclude, table.concat(search_terms,' '), export, duplicates |
|
|
|
|
return char_include, char_exclude, table.concat(search_terms,' '), export, duplicates, stackables |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -421,6 +425,25 @@ function filter_duplicates(search_result)
@@ -421,6 +425,25 @@ function filter_duplicates(search_result)
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function filter_stackables(search_result) |
|
|
|
|
for char_name, storage_list in pairs(search_result) do |
|
|
|
|
storage_list[KEY_ITEM_STORAGE_NAME] = nil |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
for char_name, storage_list in pairs(search_result) do |
|
|
|
|
for storage_name, item_list in pairs(storage_list) do |
|
|
|
|
for item_id, quantity in pairs(item_list) do |
|
|
|
|
local item = AshitaCore:GetResourceManager():GetItemById(item_id); |
|
|
|
|
if not item or item.StackSize <= 1 then |
|
|
|
|
item_list[item_id] = nil |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
return search_result |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function display_search_results(result, from_all_chars, terms, duplicates) |
|
|
|
|
local terms_pattern = build_search_pattern(terms) |
|
|
|
|
|
|
|
|
@ -508,11 +531,14 @@ end
@@ -508,11 +531,14 @@ end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function handle_command(args) |
|
|
|
|
local char_include, char_exclude, terms, export, duplicates = determine_query_elements(args) |
|
|
|
|
local char_include, char_exclude, terms, export, duplicates, stackables = determine_query_elements(args) |
|
|
|
|
local result = search(char_include, char_exclude, terms) |
|
|
|
|
if duplicates then |
|
|
|
|
result = filter_duplicates(result) |
|
|
|
|
end |
|
|
|
|
if stackables then |
|
|
|
|
result = filter_stackables(result) |
|
|
|
|
end |
|
|
|
|
local all_chars = #char_include == 0 and #char_exclude == 0 |
|
|
|
|
display_search_results(result, all_chars, terms, duplicates) |
|
|
|
|
if export ~=nil then |
|
|
|
|