Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function split(inputstr, sep)
- if(inputstr == nil or inputstr == "") then
- return nil
- end
- if sep == nil then
- sep = ","
- end
- local t={} ; i=1
- for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
- t[i] = str
- i = i + 1
- end
- return t
- end
- function clrInv(table)
- for i = 1, 16 do -- loop through the slots
- turtle.select(i)
- local x = turtle.getItemDetail(i)
- if(x ~= nil) then
- local istr = string.sub(x.name,string.find(x.name,":",0)+1)
- for key,value in pairs(table) do
- if(istr == value[1] and value[4] == "1") then
- turtle.drop()
- end
- end
- end
- end
- turtle.select(1)
- end
- if(fs.exists("listed")) then
- ifile = fs.open("listed","r")
- xlist = {}
- x = split(ifile.readLine(),',')
- while(x ~= nil and x ~= "") do
- table.insert(xlist, x)
- x = split(ifile.readLine(),',')
- end
- else
- print("Listed file does not exist, cannot clear inventory")
- end
- clrInv(xlist)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement