Advertisement
jfmachine

platform

Apr 14th, 2021
756
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.17 KB | None | 0 0
  1.  
  2. local w, l = ...
  3.  
  4. function selectBlock()
  5.  c = 2
  6.  while c <= 16 do
  7.   turtle.select(c)
  8.   if turtle.getItemCount() > 0 then
  9.    return true
  10.   end
  11.   c = c + 1
  12.  end
  13. end
  14.  
  15. function goPlace()
  16.  if turtle.getFuelLevel() <= 100 then
  17.   turtle.select(1)
  18.   turtle.refuel(1)
  19.  end
  20.  turtle.forward()
  21.  if turtle.detectDown() == false then
  22.   if turtle.placeDown() == false then
  23.    selectBlock()
  24.    turtle.placeDown()
  25.   end
  26.  end
  27. end
  28.  
  29. function turn(d)
  30.  if d == "forward" then
  31.   turtle.turnRight()
  32.   goPlace()
  33.   turtle.turnRight()
  34.   return "backward"
  35.  end
  36.  if d == "backward" then
  37.   turtle.turnLeft()
  38.   goPlace()
  39.   turtle.turnLeft()
  40.   return "forward"
  41.  end
  42. end
  43.  
  44. function start(d, w, l)
  45.  if d == "forward" then
  46.   turtle.turnLeft()
  47.   turtle.turnLeft()
  48.   while l > 0 do
  49.    goPlace()
  50.    l = l - 1
  51.   end
  52.  else
  53.  goPlace()
  54.  end
  55.  turtle.turnRight()
  56.  while w > 1 do
  57.   goPlace()
  58.   w = w - 1
  59.  end
  60.  turtle.turnRight()
  61. end
  62.  
  63. direction = "forward"
  64.  
  65. wc = tonumber(w)
  66. while wc > 0 do
  67.  lc = tonumber(l)
  68.  while lc > 0 do
  69.   goPlace()
  70.   lc = lc - 1
  71.  end
  72.  wc = wc - 1
  73.  if wc > 0 then
  74.   direction = turn(direction)
  75.  end
  76. end
  77. start(direction, tonumber(w), tonumber(l))
  78.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement