blunderhund

track

Mar 16th, 2021 (edited)
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.16 KB | None | 0 0
  1. local REG_TRACK_COUNT = 37
  2. local POWER_TRACK_COUNT = 1
  3. local rt = 1
  4. local pt = 2
  5. local totalDistance = 0
  6.  
  7. if #arg == 1 then
  8.     totalDistance = tonumber(arg[1])
  9. else
  10.     print("Please give total count of track iterations to lay so I don't go on forever.")
  11. end
  12.    
  13. function regTrack()
  14.     turtle.select(rt)
  15.     for i = 1, REG_TRACK_COUNT do
  16.         if turtle.detect() == true then
  17.             print("regTrack: Block in the way")
  18.             return false
  19.         else
  20.             print("regTrack: moving forward.")
  21.             turtle.forward()
  22.             print("regTrack: laying track.")
  23.             turtle.placeDown(1)
  24.         end
  25.     end
  26.     return true
  27. end
  28.  
  29. function powTrack()
  30.     turtle.select(pt)
  31.     for i = 1, POWER_TRACK_COUNT do
  32.         if turtle.detect() == true then
  33.             print("powTrack: Block in the way")
  34.             return false
  35.         else
  36.             print("powTrack: moving forward.")
  37.             turtle.forward()
  38.             print("powTrack: laying track.")
  39.             turtle.placeDown(1)
  40.         end
  41.     end
  42.     return true
  43. end
  44.  
  45. turtle.up()
  46. for i=1, totalDistance do
  47.     if regTrack() == true then
  48.         print("Layed reg track set.")
  49.         if powTrack() == true then
  50.             print("Layed power track set.")
  51.         else
  52.             print("Power track error.")
  53.         end
  54.     else
  55.         print("Reg track error.")
  56.     end
  57. end
  58.  
Add Comment
Please, Sign In to add comment