From ffc979c90ac3af441b4ea6e58cdbd6d6b510754b Mon Sep 17 00:00:00 2001 From: Alex Zwinge Date: Thu, 22 Jun 2017 15:43:21 -0700 Subject: [PATCH] adds support for tracking multiple mobs --- filterscan.lua | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/filterscan.lua b/filterscan.lua index 9531de7..2cfa183 100644 --- a/filterscan.lua +++ b/filterscan.lua @@ -38,7 +38,7 @@ local FilterScan = FFXiPath = ashita.file.get_install_dir(0, 1) .. '\\', MobList = { }, ZoneDatList = require('zonemoblist'), - Filter = '' + Filter = { } }; --------------------------------------------------------------------------------------------------- @@ -98,9 +98,19 @@ ashita.register_event('command', function(command, ntype) return false; end - -- Pull the filter from the command.. - FilterScan.Filter = (string.gsub(command, '/filterscan', '')):trim() - print(string.format('[FilterScan] Set new filter to: %s', FilterScan.Filter)); + -- the list of targets gets reset anytime the cmd is called. calling w/o params will 'disable' the filter + FilterScan.Filter = { } + + -- pull the target mobs from the arg and split them into the list + local filter = (string.gsub(command, '/filterscan', '')):trim() + + for target in string.gmatch(filter, "[^,]+") do + if (target ~= nil) then + table.insert(FilterScan.Filter, target:lower():trim()) + end + end + + print(string.format('[FilterScan] Set new filter to: %s', filter)); return true; end); @@ -134,17 +144,20 @@ ashita.register_event('incoming_packet', function(id, size, data) if (mobName == nil) then return false; else - -- Filter by name.. - if (mobName:lower():find(FilterScan.Filter:lower()) ~= nil) then - return false; - end - - -- Filter by target index.. - if (targetIndex == tonumber(FilterScan.Filter, 16)) then - return false; + + -- there is nothing in the filter list, so you get all the entities + if (table.getn(FilterScan.Filter) == 0) then + return false end - if (tostring(targetIndex) == FilterScan.Filter) then - return false; + + local mob = mobName:lower() + local idx_s = tostring(targetIndex) + + for _, target in pairs(FilterScan.Filter) do + if (mob:find(target) ~= nil or targetIndex == tonumber(target, 16) or idx_s == target) then + -- the mob has matched an item in the filter + return false + end end -- Ignore all non-matching entries.. -- 2.41.0.windows.1