kamilosxd678

Untitled

Feb 7th, 2016
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.13 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()) 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 placeDown()
  18.    local check = verifyInv()
  19.    
  20.    if(check) then
  21.       local d1,d2 = robot.detectDown()
  22.       if(not (d2 == "passable")) then
  23.          robot.placeDown()
  24.       end
  25.    end
  26.    
  27.    return check
  28. end
  29.  
  30. function placeUp()
  31.    local check = verifyInv()
  32.    
  33.    if(check) then
  34.       robot.placeUp()
  35.    end
  36.    
  37.    return check
  38. end
  39.  
  40. function placeForward()
  41.    local check = verifyInv()
  42.    
  43.    if(check) then
  44.       robot.place()
  45.    end
  46.    
  47.    return check
  48. end
  49.  
  50. while moving do
  51.    moving = placeUp()
  52.    if(not moving) then
  53.       break
  54.    end
  55.    
  56.    moving = placeDown()
  57.    if(not moving) then
  58.       break
  59.    end
  60.    
  61.    moving = robot.back()
  62.    if(not moving) then
  63.       break
  64.    end
  65.    
  66.    moving = placeForward()
  67.    if(not moving) then
  68.       break
  69.    end
  70. end
Advertisement
Add Comment
Please, Sign In to add comment