movescript/min/itemscript.lua

1 line
1.2 KiB
Lua
Raw Normal View History

2022-12-21 11:34:01 +00:00
a="0.0.1"local b=turtle local c={}local function d(f,g,h)return f~=nil and((not h and f.name==g)or string.find(f.name,g))end function c.makeFilter(f,g,h)local i={filterFunction=nil,fuzzy=g or false,whitelist=h}if type(f)=="string"then i.filterFunction=function(j,k)local l=d(j,f,k.fuzzy)if k.whitelist then return l else return not l end end elseif type(f)=="table"then i.filterFunction=function(j,k)for l,m in pairs(f)do if k.whitelist and d(j,m,k.fuzzy)then return true elseif not k.whitelist and not d(j,m,k.fuzzy)then return false end end return not k.whitelist end elseif type(f)=="function"then i.filterFunction=f end i.apply=function(j)return i.filterFunction(j,i)end return i end function c.totalCount(f)local g=0 for h=1,16 do local i=b.getItemDetail(h)if f.apply(i)then g=g+i.count end end return g end function c.select(f)for g=1,16 do local h=b.getItemDetail(g)if f.apply(h)then b.select(g)return true end end return false end local function e(f,g)for h=1,16 do local i=b.getItemDetail(h)if g.apply(i)then b.select(h)f()end end end function c.dropAll(f)e(b.drop,f)end function c.dropAllDown(f)e(b.dropDown,f)end function c.dropAllUp(f)e(b.dropUp,f)end function c.organize()error("Not yet implemented.")end return c