Advertisement
Guest User

Turtle_Fill

a guest
Mar 25th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.18 KB | None | 0 0
  1. --the turtle places blocks for 'height' blocks, then turns around and repeats until it has placed 'width' rows
  2.  
  3. local width = raw_input("How long do you want your build?")
  4.  
  5. local height = raw_input("How wide do you want your build?")
  6.  
  7.  
  8.  
  9. function back()
  10.  
  11.   if not turtle.back() then
  12.  
  13.     print("Something's in the way!")
  14.  
  15.     return false
  16.  
  17.   end
  18.  
  19.   return true
  20.  
  21. end
  22.  
  23. function place()
  24.  
  25.   selected = 0
  26.  
  27.   while(turtle.place() == false) do
  28.  
  29.     selected = selected + 1
  30.  
  31.     if selected == 17 then
  32.  
  33.       print("Out of blocks or block already placed!")
  34.  
  35.       return false
  36.  
  37.     end
  38.  
  39.     turtle.select(selected)
  40.  
  41.   end
  42.  
  43.   return true
  44.  
  45. end
  46.  
  47.  
  48.  
  49. for w = 1, width do
  50.  
  51.   for h = 2, height do
  52.  
  53.     if not (place() and back()) then
  54.  
  55.       return
  56.  
  57.     end
  58.  
  59.   end
  60.  
  61.   if not place() then
  62.  
  63.     return
  64.  
  65.   end
  66.  
  67.   if w % 2 == 0 then
  68.  
  69.     turtle.turnRight()
  70.  
  71.   else
  72.  
  73.     turtle.turnLeft()
  74.  
  75.   end
  76.  
  77.   if not back() then
  78.  
  79.     return
  80.  
  81.   end
  82.  
  83.   if w % 2 == 0 then
  84.  
  85.     turtle.turnRight()
  86.  
  87.   else
  88.  
  89.     turtle.turnLeft()
  90.  
  91.   end
  92.  
  93.   if not (back() and back()) then
  94.  
  95.     return
  96.  
  97.   end
  98.  
  99. end
  100.  
  101.  
  102.  
  103. print("Job finished successfully")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement