diff --git a/filterscan.lua b/filterscan.lua index 42ee0f3..76a4880 100644 --- a/filterscan.lua +++ b/filterscan.lua @@ -44,7 +44,7 @@ local FilterScan = FFXiPath = ashita.file.get_install_dir(polVersion, 1) .. '\\', MobList = { }, ZoneDatList = require('zonemoblist'), - Filter = '' + Filter = { } }; --------------------------------------------------------------------------------------------------- @@ -104,9 +104,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); @@ -140,17 +150,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..