Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. --Created By RenKylo
  2. local robot = require("robot")
  3. local component = require("component")
  4. local inv = component.inventory_controller
  5. local inv_size = robot.inventorySize()
  6. --SETTINGS
  7. local MIN_TOOL_CHARGE = 0.3 --Минимальный заряд бура
  8. local CHARGING_TIME = 10 --Время зарядки
  9. --FUNCTIONS
  10. function charging_tool() --Перезарядка бура
  11. if robot.durability() < MIN_TOOL_CHARGE then
  12. inv.equip(1)
  13. robot.dropDown(1)
  14. os.sleep(CHARGING_TIME)
  15. robot.suckDown(1)
  16. inv.equip(1)
  17. end
  18. end
  19. function robot_action() --Основные действия
  20. robot.select(1)
  21. if robot.suck() then
  22. size = robot.count(1)
  23. robot.turnRight()
  24. for i = 1, size do
  25. robot.place()
  26. robot.swing()
  27. end
  28. for n = 1, inv_size do
  29. robot.select(n)
  30. if robot.dropUp() == false and n ~= 1 then
  31. break
  32. end
  33. end
  34. robot.turnLeft()
  35. end
  36. os.sleep(0.2)
  37. end
  38. while true do
  39. if robot.durability() ~= nil then --Выполняется только если есть инструмент
  40. robot.select(1)
  41. charging_tool()
  42. robot_action()
  43. else
  44. robot.suckDown(1)
  45. inv.equip(1)
  46. end
  47. end
  48. -- бур навер от себя++
  49. -- вещи вниз
  50. --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement