Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Row 1")
- turtle.select(1)
- local listofvaluables = {'ore','iron','gold','diamond','refined','ingot','nugget','quartz','emerald','lapis','blaze','redstone','coal'}
- local listofbuilding = {'log','brick','wool','plank','door','factory','glass','bookshelf','ice','soul','chiseled','pillar','block','stair'}
- local witchery = {'witchery'}
- local ic2 = {'IC2'}
- local computercraft = {'computer','Computer','CC','disk'}
- local othertech = {'thermal','reactor','stargate','star','Thermal','BuildCraft','buildcraft'}
- local materials = {'flint','gunpower','ender'}
- local foodandplants = {'apple','raw','cooked','pam','sapling'}
- local thaumcraft = {'thaumcraft'}
- local decocraft = {'prop'}
- local function has_value (tab, val)
- for index, value in ipairs(tab) do
- if string.find(val, value) then
- return true
- end
- end
- return false
- end
- local function returntosorter()
- turtle.back()
- turtle.back()
- turtle.turnRight()
- turtle.forward()
- turtle.up()
- turtle.forward()
- end
- local function rtcfromsorter()
- turtle.back()
- turtle.down()
- turtle.back()
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- end
- local function checkitems(n)
- putintotl = {}
- for i=1,n do
- print(i)
- turtle.select(i)
- turtle.suck()
- data = turtle.getItemDetail(i)
- if data.name == nil or data.name == '' then
- print("...")
- elseif(string.find(data.name, "coal")) then
- print("found coal")
- --userinput = read()
- if(turtle.getFuelLevel() < 200) then
- print("Using coal to refuel")
- turtle.refuel()
- end
- elseif(has_value(listofvaluables, data.name)) then
- print(data.name)
- elseif(has_value(listofbuilding, data.name)) then
- print(data.name)
- elseif(has_value(witchery, data.name)) then
- print(data.name)
- elseif(has_value(ic2, data.name)) then
- print(data.name)
- elseif(has_value(computercraft, data.name)) then
- print(data.name)
- elseif(has_value(othertech, data.name)) then
- print(data.name)
- else
- print("found trash")
- print(data.name)
- table.insert(putintotl, i)
- end
- end
- itemstotrash = putintotl
- end
- local function testitems()
- itemstotrash = {}
- turtle.select(1)
- checkitems(16)
- while true do
- for i=1,table.getn(itemstotrash) do
- print(textutils.serialize(itemstotrash))
- turtle.select(itemstotrash[i])
- turtle.dropDown()
- end
- if(table.getn(itemstotrash) ~= nil) then
- checkitems(table.getn(itemstotrash))
- print("done checking another time...")
- end
- if(itemstotrash[1] == nil) then
- break
- else
- print(itemstotrash[1])
- end
- end
- end
- local function sortitems()
- turtle.forward()
- local slotswithvaluables = {}
- local slotswithbuilding = {}
- local slotswithwitchery = {}
- local slotswithic2 = {}
- local slotswithcomputercraft = {}
- local slotswithothertech = {}
- print("Sorting Items...")
- for i=1,16 do
- turtle.select(i)
- data = turtle.getItemDetail(i)
- print(data.name)
- if(data.name == nil)then
- print("...")
- elseif(has_value(listofvaluables, data.name)) then
- print("found valuable")
- table.insert(slotswithvaluables, i)
- elseif(has_value(listofbuilding, data.name)) then
- print("found valuable")
- table.insert(slotswithbuilding, i)
- elseif(has_value(witchery, data.name)) then
- print("found valuable")
- table.insert(slotswithwitchery, i)
- elseif(has_value(ic2, data.name)) then
- print("found valuable")
- table.insert(slotswithic2, i)
- elseif(has_value(computercraft, data.name)) then
- print("found valuable")
- table.insert(slotswithcomputercraft, i)
- elseif(has_value(othertech, data.name)) then
- print("found valuable")
- table.insert(slotswithothertech, i)
- end
- end
- turtle.turnLeft()
- for i=1,table.getn(slotswithvaluables) do
- print(textutils.serialize(slotswithvaluables))
- turtle.select(slotswithvaluables[i])
- turtle.drop()
- end
- turtle.turnRight()
- turtle.turnRight()
- for i=1,table.getn(slotswithbuilding) do
- print(textutils.serialize(slotswithbuilding))
- turtle.select(slotswithbuilding[i])
- turtle.drop()
- end
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- for i=1,table.getn(slotswithwitchery) do
- print(textutils.serialize(slotswithwitchery))
- turtle.select(slotswithwitchery[i])
- turtle.drop()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1,table.getn(slotswithcomputercraft) do
- print(textutils.serialize(slotswithcomputercraft))
- turtle.select(slotswithcomputercraft[i])
- turtle.drop()
- end
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- for i=1,table.getn(slotswithic2) do
- print(textutils.serialize(slotswithic2))
- turtle.select(slotswithic2[i])
- turtle.drop()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1,table.getn(slotswithothertech) do
- print(textutils.serialize(slotswithothertech))
- turtle.select(slotswithothertech[i])
- turtle.drop()
- end
- turtle.turnRight()
- turtle.back()
- turtle.back()
- turtle.back()
- end
- print("starting up...")
- while true do
- sleep(2)
- stuffinchest = redstone.getInput("right")
- if(stuffinchest == true) then
- print("Redstone signal detected...")
- returntosorter()
- testitems()
- rtcfromsorter()
- sortitems()
- term.clear()
- end
- end
RAW Paste Data