kamilosxd678

Untitled

Feb 6th, 2016
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.67 KB | None | 0 0
  1. local robot = require("robot")
  2. local moving = true
  3. local invPos = 1
  4.  
  5. function verifyInv()
  6.    if(robot.count(invPos) == 0) then
  7.       invPos = invPos + 1
  8.       if(invPos > (robot.inventorySize() - 1) or robot.count(invPos) == 0) then
  9.          return false
  10.       end
  11.       robot.select(invPos)
  12.    end
  13.    
  14.    return true
  15. end
  16.  
  17. function replaceBlock()
  18.    local check = verifyInv()
  19.    
  20.    if(check) then
  21.       robot.swingUp()
  22.       robot.placeUp()
  23.    end
  24.    
  25.    return check
  26. end
  27.  
  28. while moving do
  29.    for move=1,93 do
  30.       moving = robot.forward()
  31.       if(not moving) then
  32.          break
  33.       end
  34.    end
  35.    
  36.    if(not moving) then
  37.       break
  38.    end
  39.    
  40.    if(not replaceBlock()) then
  41.       break
  42.    end
  43.    
  44.    robot.forward()
  45.    robot.turnLeft()
  46.    robot.forward()
  47.    
  48.    if(not replaceBlock()) then
  49.       break
  50.    end
  51.    
  52.    robot.forward()
  53.    robot.turnRight()
  54.    robot.forward()
  55.    
  56.    if(not replaceBlock()) then
  57.       break
  58.    end
  59.    
  60.    robot.forward()
  61.    robot.turnLeft()
  62.    robot.forward()
  63.    
  64.    if(not replaceBlock()) then
  65.       break
  66.    end
  67.    
  68.    robot.forward()
  69.    robot.turnRight()
  70.    robot.forward()
  71.    
  72.    if(not replaceBlock()) then
  73.       break
  74.    end
  75.    
  76.    robot.forward()
  77.    robot.turnLeft()
  78.    robot.forward()
  79.    
  80.    if(not replaceBlock()) then
  81.       break
  82.    end
  83.    
  84.    robot.forward()
  85.    robot.turnRight()
  86.    robot.forward()
  87.    
  88.    if(not replaceBlock()) then
  89.       break
  90.    end
  91.    
  92.    robot.turnRight()
  93.    
  94.    for move=1,6 do
  95.       moving = robot.forward()
  96.       if(not moving) then
  97.          break
  98.       end
  99.    end
  100.    
  101.    if(not moving) then
  102.       break
  103.    end
  104.    
  105.    robot.turnLeft()
  106. end
Advertisement
Add Comment
Please, Sign In to add comment