Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 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. robot.turnLeft()
  13. inv.equip(1)
  14. robot.drop(1)
  15. os.sleep(CHARGING_TIME)
  16. robot.suck(1)
  17. inv.equip(1)
  18. robot.turnRight()
  19. end
  20. end
  21. function robot_action() --Основные действия
  22. robot.select(1)
  23. if robot.suck() then
  24. size = robot.count(1)
  25. robot.turnRight()
  26. for i = 1, size do
  27. robot.place()
  28. robot.swing()
  29. end
  30. robot.turnRight()
  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. os.sleep(0.2)
  40. end
  41. print("Hello World!")
  42. print(component.experience.level())
  43. while true do
  44. if robot.durability() ~= nil then --Выполняется только если есть инструмент
  45. robot.select(1)
  46. charging_tool()
  47. robot_action()
  48. end
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement