TheKojent

Turbo Tree Overflow

Dec 26th, 2014
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.69 KB | None | 0 0
  1. rednet.open("left")
  2.  
  3. local mainID = 15
  4.  
  5. local function forward(count)
  6.     for k = 1,count do
  7.         turtle.forward()
  8.     end
  9. end
  10.  
  11. local function goUp(count)
  12.     for k = 1,count do
  13.         turtle.up()
  14.     end
  15. end
  16.  
  17. local function goDown(count)
  18.     for k = 1,count do
  19.         turtle.down()
  20.     end
  21. end
  22.  
  23. while true do
  24.     while turtle.getItemCount() == 0 do    --Get items
  25.         if not turtle.suck() then
  26.             rednet.send(mainID, "home")
  27.             sleep(.5)
  28.             local a = 5
  29.             while a ~= 0 do
  30.                 rednet.send(mainID, tostring(a))
  31.                 sleep(60)
  32.             end
  33.             rednet.send(mainID, tostring(a))
  34.         end
  35.     end
  36.    
  37.     rednet.send(mainID, "away")
  38.     local data = turtle.getItemDetail()
  39.    
  40.     if data.name == "minecraft:log" then    --Sort logs
  41.         turtle.turnRight()
  42.         turtle.turnRight()
  43.         forward(8)
  44.         turtle.turnLeft()
  45.         goDown(2)
  46.         if not turtle.drop() then   --Try to put in one of 3 chests
  47.             goDown(1)
  48.             if not turtle.drop() then
  49.                 turtle.dropDown()
  50.                 goUp(1)
  51.             end
  52.             goUp(1)
  53.         end
  54.         goUp(2)
  55.         turtle.turnLeft()
  56.         forward(8)
  57.     elseif data.name == "minecraft:sapling" then    --Sort saplings
  58.         turtle.turnRight()
  59.         goDown(2)
  60.         if not turtle.drop() then
  61.             goDown(1)
  62.             if not turtle.drop() then
  63.                 turtle.dropDown()
  64.             end
  65.             goUp(1)
  66.         end
  67.         goUp(2)
  68.     elseif data.name == "minecraft:coal" then   --Sort charcoal, refuel if needed
  69.         if turtle.getFuelLevel() < (turtle.getFuelLimit() - 5120) then
  70.             turtle.refuel()
  71.         else
  72.             goDown(3)
  73.             turtle.dropDown()
  74.             goUp(3)
  75.         end
  76.     else    --Sort everything else
  77.         turtle.turnRight()
  78.         turtle.turnRight()
  79.         forward(8)
  80.         turtle.turnLeft()
  81.         goDown(4)
  82.         if not turtle.drop() then
  83.             turtle.dropDown()
  84.         end
  85.         goUp(4)
  86.         turtle.turnLeft()
  87.         forward(8)
  88.     end
  89. end
  90.  
  91. rednet.close("left")
Advertisement
Add Comment
Please, Sign In to add comment