Advertisement
Knito

new-3x3.lua

Feb 19th, 2024 (edited)
106
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.92 KB | Source Code | 0 0
  1. -- pastebin get kZaXMD1Y
  2.  
  3. -- Normally for 3 recipes which compact 3 different ore reeds to ingots
  4. -- you would use 3 crafters. This is the all-in-one solution.
  5. -- One turtle for many 3x3 recipes.
  6.  
  7. -- Made by Konitor 2024
  8.  
  9. -- this turtle compacts 3x3 recipes. Originally made for a
  10. -- ore reed farm which delivered different reeds to be compacted
  11. -- to different ore ingots.
  12. -- front chest = input chest. Make sure it has enough empty space
  13. -- for the turtle to put back its contents.
  14. -- down chest = output chest. Have a pipe system on it to always keep it empty.
  15.  
  16. -- you need a crafting turtle!!!!
  17.  
  18. -- crafted how many items so far?
  19.  
  20. crafted = 0
  21.  
  22. -- Check to see if I'm alright and ready for crafting
  23.  
  24. bCrafting = (peripheral.getType("left") == "workbench") or (peripheral.getType("right") == "workbench")
  25. if not bCrafting then
  26.   error("I want to be a crafty turtle! Craft me together with a crafting table.")
  27. end
  28.  
  29. --Auto Label
  30.  
  31. if os.getComputerLabel() == nil then
  32.   os.setComputerLabel("new-3x3")
  33. end
  34.  
  35. -- copy this program to startup when its not "startup"
  36.  
  37. me = fs.getName( shell.getRunningProgram() )
  38.  
  39. if( me ~=  "startup") then
  40.     print( "Overwriting startup with "..me )
  41.     if( fs.exists("startup") ) then
  42.         fs.delete("startup")
  43.     end
  44.     fs.copy( me, "startup" )
  45. end
  46.  
  47.  
  48. print( "Front chest = input" )
  49. print( "Down chest = output" )
  50. print( "Konitor 2024" )
  51.  
  52. -- first stack is selected after clearing
  53.  
  54. function cleartablebiggestfirst()
  55.  
  56.     local biggeststack = 0
  57.     local biggestnum = 0
  58.  
  59.     for i=1, 16 do
  60.  
  61.         n = turtle.getItemCount( i )
  62.         if n > biggestnum then
  63.             biggeststack = i
  64.             biggestnum = n
  65.         end
  66.        
  67.     end
  68.    
  69.     if biggeststack > 0 then
  70.         turtle.select( biggeststack )
  71.         turtle.drop()
  72.     end
  73.        
  74.     for i = 16, 1, -1 do
  75.         turtle.select(i)
  76.         turtle.drop()
  77.     end
  78.  
  79.     sleep( 1 )
  80.    
  81. end
  82.  
  83. while true do
  84.  
  85.     cleartablebiggestfirst()
  86.  
  87.     docraft = true
  88.  
  89.     if turtle.suck(64) then
  90.    
  91.         n = turtle.getItemCount( 1 )
  92.         r = n % 9
  93.         anz = math.floor( n / 9 )
  94.        
  95.         if( anz > 0 ) then
  96.        
  97.             turtle.transferTo( 2, anz )    
  98.             turtle.transferTo( 3, anz )
  99.             turtle.transferTo( 5, anz )
  100.             turtle.transferTo( 6, anz )
  101.             turtle.transferTo( 7, anz )
  102.             turtle.transferTo( 9, anz )
  103.             turtle.transferTo( 10, anz )
  104.             turtle.transferTo( 11, anz )
  105.            
  106.         else
  107.        
  108.             docraft = false
  109.            
  110.            
  111.         end
  112.  
  113.     else
  114.    
  115.         docraft = false
  116.        
  117.     end
  118.  
  119.  
  120.     if docraft then
  121.        
  122.         turtle.craft( anz )
  123.         -- drop rest of slot 1 back to source chest
  124.        
  125.         if r == 0 then
  126.         -- Slot 1 contains crafted item
  127.         turtle.dropDown()
  128.         else
  129.         -- Slot 1 contains input item - drop it back
  130.         turtle.drop()
  131.         end
  132.        
  133.         -- drop crafted items into target chest
  134.         turtle.select(2)
  135.         turtle.dropDown()
  136.        
  137.         crafted = crafted + anz
  138.        
  139.         print( "crafted " .. crafted .. " items")
  140.        
  141.     else
  142.    
  143.         cleartablebiggestfirst()
  144.    
  145.         for i = 1, 16 do
  146.             turtle.suck()
  147.         end
  148.        
  149.         cleartablebiggestfirst()
  150.    
  151.     end
  152.  
  153. end
  154.  
Advertisement
Comments
  • Knito
    78 days
    # text 0.47 KB | 0 0
    1. pastebin get kZaXMD1Y new-3x3
    2.  
    3. One crafting turtle for many 3x3 recipes.
    4. For the "ore reed" mod.
    5. One crafting turtle uses the harvests chest in front and crafts everything to ores. The harvest chest may contain different reeds at the same time. Ore output is bottom chest. I suggest using a pipe mod to transfer crafted items to a drawers system.
    6.  
    7. I recommend the harvest system from Kaikaku. https://www.youtube.com/watch?v=Oz2xnDchqFg
    8. pastebin get ZVc6H649 aHarvester
    9.  
Add Comment
Please, Sign In to add comment
Advertisement