Advertisement
Guest User

test

a guest
Feb 19th, 2020
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.62 KB | None | 0 0
  1. width = 20
  2. height = 20
  3.  
  4. width = width - 1
  5.  
  6. -- Draw screen
  7. term.setCursorPos(1, 1)
  8. term.setTextColor(colors.black)
  9. term.setBackgroundColor(colors.white)
  10. term.clear()
  11. term.setTextColor(colors.lime)
  12. term.setBackgroundColor(colors.black)
  13. term.clearLine()
  14. print("           Turtle Farm v1.0            ")
  15. term.setCursorPos(1, 3)
  16. term.setTextColor(colors.gray)
  17. term.setBackgroundColor(colors.white)
  18. print("Round ")
  19. print()
  20. term.setTextColor(colors.lightGray)
  21. term.write("[ ] ")
  22. term.setTextColor(colors.black)
  23. print("Dumping inventory")
  24. term.setTextColor(colors.lightGray)
  25. term.write("[ ] ")
  26. term.setTextColor(colors.black)
  27. print("Refueling")
  28. term.setTextColor(colors.lightGray)
  29. term.write("[ ] ")
  30. term.setTextColor(colors.black)
  31. print("Getting seeds")
  32. term.setTextColor(colors.lightGray)
  33. term.write("[ ] ")
  34. term.setTextColor(colors.black)
  35. print("Checking blocks")
  36. term.setTextColor(colors.lightGray)
  37. term.write("    [ ] ")
  38. term.setTextColor(colors.black)
  39. print("Harvesting")
  40. term.setTextColor(colors.lightGray)
  41. term.write("    [ ] ")
  42. term.setTextColor(colors.black)
  43. print("Replanting")
  44. term.setTextColor(colors.lightGray)
  45. term.write("[ ] ")
  46. term.setTextColor(colors.black)
  47. print("Going home")
  48.  
  49. round = 0
  50.  
  51. while true do
  52.     round = round + 1
  53.    
  54.     term.setTextColor(colors.black)
  55.     term.setCursorPos(7, 3)
  56.     term.write(round)
  57.  
  58.     term.setCursorPos(2, 5)
  59.     term.write("*")
  60.     turtle.turnRight()
  61.     for i=1,16 do
  62.         turtle.select(i)
  63.         turtle.drop()
  64.     end
  65.     term.setCursorPos(2, 5)
  66.     term.write(" ")
  67.    
  68.     term.setCursorPos(2, 6)
  69.     term.write("*")
  70.     turtle.turnRight()
  71.     turtle.select(1)
  72.     term.setTextColor(colors.lightGray)
  73.     while turtle.getFuelLevel() < (width+1)*(height+1)*2 do
  74.         term.setCursorPos(15, 6)
  75.         term.write(turtle.getFuelLevel().."/"..((width+1)*(height+1)*2).."   ")
  76.         turtle.suck(1)
  77.         turtle.refuel(1)
  78.     end
  79.     term.setTextColor(colors.black)
  80.     term.setCursorPos(15, 6)
  81.     term.write("                   ")
  82.     term.setCursorPos(2, 6)
  83.     term.write(" ")
  84.  
  85.     term.setCursorPos(2, 7)
  86.     term.write("*")
  87.     turtle.turnRight()
  88.     turtle.suck(64)
  89.     turtle.select(2)
  90.     term.setCursorPos(2, 7)
  91.     term.write(" ")
  92.  
  93.     turtle.turnRight()
  94.  
  95.     turtle.up()
  96.     turtle.forward()
  97.  
  98.     for x=0,width do
  99.         for y=0,height do
  100.             term.setCursorPos(2, 8)
  101.             term.write("*")
  102.             term.setCursorPos(21, 8)
  103.             term.setTextColor(colors.lightGray)
  104.             term.write("["..x..","..y.."]      ")
  105.             term.setTextColor(colors.black)
  106.             local success, data = turtle.inspectDown()
  107.             local seeds
  108.             seeds = false
  109.             if success then
  110.                 if data.name == "minecraft:wheat" and data.metadata == 7 then
  111.                     term.setCursorPos(2, 8)
  112.                     term.write(" ")
  113.                     term.setCursorPos(6, 9)
  114.                     term.write("*")
  115.                     turtle.digDown()
  116.                     term.setCursorPos(6, 9)
  117.                     term.write(" ")
  118.                     seeds = true
  119.                 end
  120.             else
  121.                 term.setCursorPos(2, 8)
  122.                 term.write(" ")
  123.                 term.setCursorPos(6, 9)
  124.                 term.write("*")
  125.                 turtle.digDown()
  126.                 term.setCursorPos(6, 9)
  127.                 term.write(" ")
  128.                 seeds = true
  129.             end
  130.            
  131.             if seeds then
  132.                 term.setCursorPos(6, 10)
  133.                 term.write("*")
  134.                 if turtle.getItemCount(1) < 2 and turtle.getItemCount(1) ~= 0 then
  135.                     term.setTextColor(colors.lightGray)
  136.                     term.setCursorPos(20, 10)
  137.                     term.write("Searching for seeds")
  138.                     for i=2,16 do
  139.                         if turtle.getItemCount(i) > 0 then
  140.                             local data = turtle.getItemDetail(i)
  141.                             local original = turtle.getItemDetail(1)
  142.                             if data.name == original.name then
  143.                                 turtle.select(i)
  144.                                 turtle.transferTo(1)
  145.                                 break
  146.                             end
  147.                         end
  148.                     end
  149.                     term.setCursorPos(20, 10)
  150.                     term.write("                       ")
  151.                     term.setTextColor(colors.black)
  152.                 end
  153.            
  154.                 turtle.select(1)
  155.                 turtle.placeDown()
  156.                 turtle.select(2)
  157.                 term.setCursorPos(6, 10)
  158.                 term.write(" ")
  159.             end
  160.            
  161.             if (y < (height - 1)) then
  162.                 turtle.forward()
  163.             end
  164.         end
  165.         if x ~= width then
  166.             if (x % 2 == 1) then
  167.                 turtle.turnRight()
  168.                 turtle.forward()
  169.                 turtle.turnRight()
  170.             else
  171.                 turtle.turnLeft()
  172.                 turtle.forward()
  173.                 turtle.turnLeft()
  174.             end
  175.         end
  176.     end
  177.     term.setCursorPos(21, 8)
  178.     term.write("                   ")
  179.     term.setCursorPos(2, 8)
  180.     term.write(" ")
  181.     term.setCursorPos(2, 11)
  182.     term.write("*")
  183.     turtle.forward()
  184.     if (width % 2 == 0) then
  185.         turtle.turnLeft()
  186.         turtle.turnLeft()
  187.         local i = 1
  188.         if (height % 2 == 0) then i = 0 end
  189.         for x=0,height-i do turtle.forward() end
  190.         turtle.turnLeft()
  191.     else
  192.         turtle.turnLeft()
  193.         turtle.forward()
  194.     end
  195.    
  196.     local i = 0
  197.     if (width % 2 == 1) then i = 1 end
  198.     for x=1,width-i do turtle.forward() end
  199.     turtle.turnLeft()
  200.     turtle.down()
  201.     term.setCursorPos(2, 11)
  202.     term.write(" ")
  203. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement