-- compact3x3 -- by Konitor 2019-09-10 -- minecraft computercraft turtle program -- compacting nuggets to ingots, ingots to blocks, gobber globettes to globs -- -- pastebin get VYDsTmsL compact3x3 -- setup: front chest = input -- down chest = output and dropoff chest for cleanup -- -- Example environment for "Gobber globettes to globs": -- The mod "Simple Storage Network" does export globettes to -- the front chest and import everything from the down chest. -- When there are globettes in the down chest they get -- exported again to the front chest. So no problem to clean the -- crafting area to the down chest on startup after an error -- has occured. -- -- sustaining: can get stopped anytime and will startup safely -- after world reload, chunk reload, game crash etc. -- will sit and do nothing on error condition but tell you. -- Only error atm: I'm not a crafty turtle! That's a show stopper. -- Program overview: -- First check if the turtle is a crafty turtle. -- Then check for a label and label it when it has none. -- Then copy this program to "startup" for self sustain. -- Then start by cleaning up the internal buffer to the down chest. -- Main loop: -- Get 9 same items from front chest -- Craft -- Drop to down chest -- Wait a little -- Do it again. -- crafted how many items so far? crafted = 0 -- Check to see if I'm alright and ready for crafting bCrafting = (peripheral.getType("left") == "workbench") or (peripheral.getType("right") == "workbench") if not bCrafting then error("I want to be a crafty turtle! Craft me together with a crafting table.") end --Auto Label if os.getComputerLabel() == nil then os.setComputerLabel("Compact3x3") end -- copy this program to startup when its not "startup" me = fs.getName( shell.getRunningProgram() ) if( me ~= "startup") then print( "Overwriting startup with "..me ) if( fs.exists("startup") ) then fs.delete("startup") end fs.copy( me, "startup" ) end print( "Front chest = input" ) print( "Down chest = output" ) sleep( 3 ) -- looking blankly at info, yeah! -- cleaning up the crafting buffer after restart -- clear inventory to dropoff chest for i = 1, 16 do turtle.select(i) turtle.dropDown() end -- Main loop while true do -- fill up the crafting area -- this can take more than one loop -- break when docraft == false and -- wait 3 secs for another attempt -- to complete the rest of the 3x3 area -- craft only when docraft still true docraft = true -- 1st row of 3x3 grid if( turtle.getItemCount(1) == 0 ) then turtle.select(1) if not turtle.suck(1) then docraft = false end end if( turtle.getItemCount(2) == 0 ) then turtle.select(2) if not turtle.suck(1) then docraft = false end end if( turtle.getItemCount(3) == 0 ) then turtle.select(3) if not turtle.suck(1) then docraft = false end end -- 2nd row of 3x3 grid if( turtle.getItemCount(5) == 0 ) then turtle.select(5) if not turtle.suck(1) then docraft = false end end if( turtle.getItemCount(6) == 0 ) then turtle.select(6) if not turtle.suck(1) then docraft = false end end if( turtle.getItemCount(7) == 0 ) then turtle.select(7) if not turtle.suck(1) then docraft = false end end -- 3th row of 3x3 grid if( turtle.getItemCount(9) == 0 ) then turtle.select(9) if not turtle.suck(1) then docraft = false end end if( turtle.getItemCount(10) == 0 ) then turtle.select(10) if not turtle.suck(1) then docraft = false end end if( turtle.getItemCount(11) == 0 ) then turtle.select(11) if not turtle.suck(1) then docraft = false end end if docraft == true then -- just enough items if turtle.craft() then turtle.dropDown() crafted = crafted + 1 print( "crafted "..crafted.." items" ) -- give the system a break, don't harm fps sleep( 1 ) else print ("Crafting failed after crafting "..crafted.." items.") -- cleaning up the crafting buffer after error -- clear inventory to dropoff chest for i = 1, 16 do turtle.select(i) turtle.dropDown() end sleep( 3 ) end else -- not enough items -- wait for items, don't insist too much, don't harm fps sleep( 3 ) end end