TitanChase

Untitled

Aug 18th, 2020 (edited)
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.21 KB | None | 0 0
  1. local robot = require("robot")
  2. local computer = require("computer")
  3. local shell = require("shell")
  4.  
  5.  
  6. function buildLayer()
  7.     place3()
  8.     robot.turnRight()
  9.     robot.forward()
  10.     robot.turnRight()  
  11.     robot.back()
  12.     place3()
  13.     robot.turnLeft()
  14.     robot.forward()
  15.     robot.turnLeft()  
  16.     robot.back()
  17.     place3()
  18. end
  19.  
  20. function place3()
  21.     for i = 0, 2, 1 do
  22.         robot.forward()
  23.         robot.placeDown()
  24.     end
  25. end
  26.  
  27. function buildRedstoneLayer()
  28.     place3()
  29.     robot.turnRight()
  30.     robot.forward()
  31.     robot.turnRight()
  32.     robot.placeDown()
  33.     robot.forward()
  34.     robot.select(2)
  35.     robot.placeDown()
  36.     robot.select(1)
  37.     robot.forward()
  38.     robot.placeDown()
  39.     robot.turnLeft()
  40.     robot.forward()
  41.     robot.turnLeft()  
  42.     robot.back()
  43.     place3()
  44. end
  45.  
  46. function returnToStart()
  47.     for i = 0, 3, 1 do
  48.         robot.back()
  49.     end
  50.     for i = 0, 2, 1 do
  51.         robot.down()
  52.     end
  53.     robot.turnLeft()
  54.     robot.forward()
  55.     robot.forward()
  56.     robot.turnRight()
  57. end
  58.  
  59. function dropRedstone()
  60.     robot.select(3)
  61.     robot.drop(1)
  62.     robot.select(1)
  63. end
  64.  
  65. function reload()
  66.     robot.up()
  67.     robot.turnRight()
  68.     robot.forward()
  69.     robot.forward()
  70.     robot.turnRight()
  71.     robot.select(1)
  72.     robot.suck(26)
  73.     robot.turnLeft()
  74.     robot.forward()
  75.     robot.turnRight()
  76.     robot.select(2)
  77.     robot.suck(1)
  78.     robot.turnLeft()
  79.     robot.forward()
  80.     robot.turnRight()
  81.     robot.select(3)
  82.     robot.suck(1)
  83.     robot.turnRight()
  84.     robot.down()
  85.     for i = 0, 3, 1 do
  86.         robot.forward()
  87.     end
  88.     robot.turnRight()
  89.     robot.select(1)
  90. end
  91.  
  92.  
  93.  
  94. function checkPower()
  95.     return computer.energy() / computer.maxEnergy() < 0.3
  96. end
  97.  
  98. local args, ops = shell.parse(...)
  99.  
  100. for i = 0, args[1] - 1 , 1 do
  101.     reload()
  102.  
  103.     robot.forward()
  104.  
  105.     if checkPower() then
  106.         shell.execute('recharge')
  107.     end
  108.  
  109.     robot.up()
  110.     buildLayer()
  111.     robot.up()
  112.     robot.turnLeft()
  113.     robot.turnLeft()
  114.     robot.back()
  115.     buildRedstoneLayer()
  116.     robot.up()
  117.     robot.turnLeft()
  118.     robot.turnLeft()
  119.     robot.back()
  120.     buildLayer()
  121.     returnToStart()
  122.     dropRedstone()
  123.     os.sleep(10)
  124. end
Add Comment
Please, Sign In to add comment