Advertisement
ChicagoFire3

LazerTree

Oct 25th, 2021
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. if not term.isColor() then
  2. print("Advanced computer required")
  3. error()
  4. end
  5.  
  6. local sides = peripheral.getNames()
  7. treefarms = {}
  8. for _, side in pairs(sides) do
  9. if peripheral.getType(side) == "warpdriveLaserTreeFarm" then
  10. print("Wrapping " .. side)
  11. table.insert(treefarms, peripheral.wrap(side))
  12. end
  13. end
  14.  
  15.  
  16. local noExit = true
  17. breakLeaves = true
  18. tapTrees = true
  19. silktouch = false
  20. local args = {...}
  21. if #args > 0 then
  22. if args[1] == "help" or args[1] == "?" then
  23. print("Usage: farm <breakLeaves> <tapTrees> <silktouch>")
  24. print()
  25. print("Farmer always farms above it.")
  26. print("Use 'true' or '1' to enable an option.")
  27. print("Use 'false' or '0' to disable an option.")
  28. print("Default is to break leaves and tap rubber trees.")
  29. print("Sapplings will be automatically replanted.")
  30. print("Farming automatically stops when inventory is full.")
  31. print()
  32. noExit = false
  33. else
  34. if args[1] == "false" or args[1] == "0" then
  35. breakLeaves = false
  36. end
  37. end
  38.  
  39. if #args > 1 then
  40. if args[2] == "false" or args[2] == "0" then
  41. tapTrees = false
  42. end
  43. end
  44.  
  45. if #args > 2 then
  46. if args[3] == "true" or args[3] == "1" then
  47. silktouch = true
  48. end
  49. end
  50. end
  51.  
  52. if #treefarms == 0 then
  53. term.setBackgroundColor(colors.red)
  54. term.setTextColor(colors.white)
  55. term.write("No laser tree farm detected")
  56.  
  57. noExit = false
  58. end
  59. if noExit then
  60. for _, treefarm in pairs(treefarms) do
  61. local _, isActive = treefarm.state()
  62. if not isActive then
  63. treefarm.breakLeaves(breakLeaves)
  64. treefarm.tapTrees(tapTrees)
  65. treefarm.silktouch(silktouch)
  66.  
  67. treefarm.start()
  68. end
  69. end
  70. os.sleep(1)
  71. end
  72.  
  73. local label = os.getComputerLabel()
  74. if label then
  75. else
  76. label = "" .. os.getComputerID()
  77. end
  78.  
  79. term.setTextColor(colors.blue)
  80. if noExit then
  81. local areActive
  82. repeat
  83. areActive = false
  84. for key, treefarm in pairs(treefarms) do
  85. local status, isActive, energy, totalHarvested, currentValuable, totalValuables = treefarm.state()
  86.  
  87. term.setBackgroundColor(colors.black)
  88. term.clear()
  89. term.setBackgroundColor(colors.lime)
  90. term.setCursorPos(1, 1)
  91. term.write(label .. " - Laser tree farm " .. key .. " of " .. #treefarms)
  92. term.setBackgroundColor(colors.black)
  93. term.setCursorPos(1, 3)
  94. term.write("Status: " .. status .. " ")
  95. term.setBackgroundColor(colors.black)
  96. term.setCursorPos(1, 5)
  97. term.write("Energy level is " .. energy .. " EU")
  98. term.setCursorPos(1, 7)
  99. term.write("Farmed " .. currentValuable .. " out of " .. totalValuables .. " blocks in current cycle ")
  100. term.setCursorPos(1, 9)
  101. term.write("Harvested " .. totalHarvested .. " items and counting... ")
  102.  
  103. if isActive then
  104. areActive = true
  105. os.sleep(1)
  106. else
  107. os.sleep(0.1)
  108. end
  109. end
  110. until not areActive
  111. end
  112.  
  113. term.setBackgroundColor(colors.black)
  114. term.setTextColor(colors.white)
  115.  
  116. print()
  117. print("Program closed")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement