Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

45 Commits

Repository files navigation

Top languageFile size

filterTable

A Lua/Roblox function made to filter and deep search values inside a table blazingly fast, with custom filter options and a "Next Scan" method, making filtering dynamic/specific values way easier.

Documentation:

filterOptions= {
type=<luatype>searchesforthespecificgiventypefirstMatchOnly=<bool>whetherornotonlythefirstmatchedvaluewillbereturnedlogPath=<bool>logsthepathtakenbythefilterTable, maydecreaseperformancedeepSearch=<bool>searcheseveryfunctionconstants, upvalues, protosandenv (willdecreaseperformance)
validator=<<bool>function(i,v)>validatesanentryusingafunction**willoverridethedefaultchecking, sousinganyoptionspresentedbelowwillnotwork**
}
extrafilterOptionsforspecifictypes:
function->name=<functionname>upvalues=<exactupvaluestableoffunction>constants=<exactconstantstableoffunction>protos=<exactprotostableoffunction>matchUpvalues=<tablewithrequiredupvaluesoffunction>matchConstants=<tablewithrequiredconstantsoffunction>matchProtos=<tablewithrequiredprotosoffunction>upvalueAmount=<upvalueamountoffunction>constantAmount=<constantamountoffunction>protoAmount=<protoamountoffunction>info=<exactdebug.infotableoffunction>matchInfo=<tablewithrequireddebug.infooffunction>ignoreEnv=<bool>script=<Instance<script>>**onlyforfunctionswith"script"definedintheirenv**table->tableMatch= {index=<tableindex>, value=<tablevalue>, validator=<validator>}
tableSize=<sizeoftable>metatable=<exactmetatableoftable>hasMetatable=<bool>userdata->metatable=<exactmetatableoftable>hasMetatable=<bool>
[robloxtype] ->className=<string>property=<<string>robloxpropertyname>forcheckingpropertiesofobjects, e.gcheckingtheCFramepropertyofBasePart's->{type="Instance", classname="BasePart", property="CFrame", value=CFrame.new()}returnformat= {
{
Value,
Index,
Parent,
SearchId,
(additionalvalues)
},
(...)
}

Usage:

localtbl= {"testing", {"testing"}}
localresults=filterTable(tbl, {type="string", value="testing"})
fori,vinpairs(results) do-- you can also use results.print() instead of thistable.foreach(v, print)
-- expected output:--[[ Index 1 Value testing Parent table: 0x0000000000000000 (this is equivalent to tbl) SearchId a7HS (random) Index 1 Value testing Parent table: 0x0000000000000001 (this is equivalent to tbl[2]) SearchId a7HS (random)]]end

Next Scan usage example:

localtbl= {"testing", {"testing"}}
localresults=filterTable(tbl, {type="string", value="testing"}) -- will return 2 valuestbl[1] ="not testing" -- change one of the valuesresults=results.nextScan({type="string", value="testing"}) -- will return only 1 value (the unchanged one)fori,vinpairs(results) dotable.foreach(v, print)
-- expected output:--[[ Index 1 Value testing Parent table: 0x0000000000000001 (this is equivalent to tbl[2]) SearchId 65CA (random)]]end

Example usage on a roblox game (searching every single lua object in the garbage collector with deepSearch in 0.03s)

04b14f521b398d1a942769b7a3a2b468.mp4
Display Method

Instead of looping through results and printing each results table manually you can use the display(limit) method appended to every result of filterTable.

limit is the max amount of results to be displayed, if its nil, it will print every entry

localtbl= {"testing", {"testing"}}
localresults=filterTable(tbl, {type="string", value="testing"})
results.display()
-- expected output:--[[filterTable (result #1)Index 1Value testingParent table: 0x0000000000000000 (this is equivalent to tbl)SearchId klF1 (random)filterTable (result #2)Index 1Value testingParent table: 0x0000000000000001 (this is equivalent to tbl[2])SearchId klF1 (random)]]

About

Lua/Roblox function to filter and deep search specific values inside tables blazingly fast

Topics

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages