Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. --Created By RenKylo
  2. --Updated by tonupboy
  3. local robot = require("robot")
  4. local component = require("component")
  5. local inv = component.inventory_controller
  6. local inv_size = robot.inventorySize()
  7. --FUNCTIONS
  8. function robot_clear_bag()
  9. robot.suck(1) -- подобрать 1 слот из сундука
  10. os.sleep(1)
  11. robot.select(1) -- выбрать первый слот
  12. os.sleep(1)
  13. robot.turnRight() -- повернуть направо (лицом к пустому блоку)
  14. os.sleep(1)
  15. robot.use() -- пкм на слоте
  16. os.sleep(1)
  17. robot.suck(1) -- последовательно выложить все предметы из него в инвентарь
  18. os.sleep(1)
  19. robot.suck(2)
  20. os.sleep(1)
  21. robot.suck(3)
  22. os.sleep(1)
  23. robot.suck(4)
  24. os.sleep(1)
  25. robot.suck(5)
  26. os.sleep(1)
  27. robot.turnRight() -- повернуться направо
  28. os.sleep(1)
  29. -- вылоижть все из инвентаря в сундук
  30. os.sleep(1)
  31. for n = 1, inv_size do
  32. robot.select(n)
  33. if robot.drop() == false and n ~= 1 then
  34. break
  35. end
  36. end
  37. robot.turnAround()
  38. end
  39. function charging_tool() --Перезарядка бура
  40. if robot.durability() < MIN_TOOL_CHARGE then
  41. robot.turnLeft()
  42. inv.equip(1)
  43. robot.drop(1)
  44. os.sleep(CHARGING_TIME)
  45. robot.suck(1)
  46. inv.equip(1)
  47. robot.turnRight()
  48. end
  49. end
  50.  
  51. function robot_action() --Основные действия
  52. robot.select(1)
  53. if robot.suck() then
  54. size = robot.count(1)
  55. robot.turnRight()
  56. for i = 1, size do
  57. robot.place()
  58. robot.swing()
  59. end
  60. robot.turnRight()
  61. for n = 1, inv_size do
  62. robot.select(n)
  63. if robot.drop() == false and n ~= 1 then
  64. break
  65. end
  66. end
  67. robot.turnAround()
  68. end
  69. os.sleep(0.2)
  70. end
  71. function robot_setup() --Осмотреться и занять стартовое положение.
  72. for n = 1, 4 do
  73. block = robot.detect()
  74. print("Have block: ", block)
  75. if block == false then
  76. robot.turnLeft()
  77. break
  78. end
  79. robot.turnLeft()
  80. os.sleep(0.2)
  81. end
  82. end
  83. print("My level is: ")
  84. print(component.experience.level())
  85. robot_setup()
  86. robot_clear_bag()
  87. -- while true do
  88. -- if robot.durability() ~= nil then --Выполняется только если есть инструмент
  89. -- robot.select(1)
  90. -- charging_tool()
  91. -- robot_action()
  92. -- end
  93. -- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement