Advertisement
GauHelldragon

gauRailer v0.2

Aug 26th, 2014
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.01 KB | None | 0 0
  1. local railEnd = 4
  2. local brickEnd = 8
  3.  
  4. local currentRail = 1
  5. local currentBrick = railEnd+1
  6.  
  7. function DigIt()
  8.     turtle.turnLeft()
  9.     turtle.turnLeft()
  10.     turtle.dig()
  11.     turtle.turnRight()
  12.     turtle.turnRight()
  13. end
  14.  
  15. function placeBrick()  
  16.     turtle.select(currentBrick)
  17.     turtle.placeDown()
  18.     if ( turtle.getItemCount(currentBrick) <= 0 ) then
  19.         currentBrick = currentBrick + 1
  20.     end
  21. end
  22.  
  23. function placeTrack()  
  24.     turtle.select(currentRail)
  25.     turtle.place()
  26.     if ( turtle.getItemCount(currentRail) <= 0 ) then
  27.         currentRail = currentRail + 1
  28.     end
  29. end
  30.  
  31. function LayTrack()
  32.     if ( not turtle.back() ) then
  33.         DigIt()
  34.     end
  35.     turtle.digDown()
  36.     placeBrick()
  37.     placeTrack()
  38. end
  39.  
  40. function countBlocks()
  41.     local tracks = 0
  42.     local bricks = 0
  43.     for slot = 1,railEnd do
  44.         tracks = tracks + turtle.getItemCount(slot)
  45.     end
  46.     for slot = railEnd+1,brickEnd do
  47.         bricks = bricks + turtle.getItemCount(slot)
  48.     end
  49.     return math.min(bricks,tracks)
  50.  
  51. end
  52.  
  53.  
  54. local distance = countBlocks()
  55.  
  56. for x=1,distance do
  57.     LayTrack()
  58.  
  59. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement