Advertisement
serafim7

quarry marker [OpenComputers]

Nov 8th, 2016
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.46 KB | None | 0 0
  1. -- установщик маркеров в шахте, для карьера bildcraft by serafim  http://pastebin.com/pd035mnV
  2. -- положить в слот 1 маркеры, 4 штуки
  3. -- дать в руку робота кирку
  4. -- пример запуска: bild 63  ,63 - длинна рамки
  5.  
  6. local a = {...}
  7. local length = tonumber(a[1]) or 63
  8. local com = require('component')
  9.  
  10. if not com.isAvailable("robot") then
  11.   print("только роботы могут использовать эту программу")
  12.   os.exit()
  13. end
  14. local robot = require("robot")
  15.  
  16. if length < 4 then
  17.   print("длинна рамки должна быть больше 4")
  18.   os.exit()
  19. end
  20.  
  21. if robot.count(1) < 4 then
  22.   print("положите 4 маркера в слот № 1")
  23.   os.exit()
  24. end
  25.  
  26. function bild()
  27.   robot.select(1)
  28.   print("строю рамку длинной: "..length)
  29.   for j = 1, 4 do
  30.     for i = 1, length do
  31.       while robot.detectUp() do
  32.         robot.swingUp()
  33.       end
  34.       while robot.detect() do
  35.         robot.swing()
  36.       end
  37.       while not robot.forward() do
  38.         robot.swing()
  39.       end
  40.         if i == length then
  41.           robot.swingDown()
  42.             if robot.placeDown() then
  43.               print("ставлю маркер № "..j)
  44.             else
  45.               print("не могу поставить маркер № "..j)
  46.             end
  47.         end
  48.     end
  49.       robot.turnRight()
  50.   end
  51. end
  52.  
  53. bild()
  54. print("готово")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement