wikiwa

turtle floor maker

Jan 14th, 2015
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.26 KB | None | 0 0
  1. -- 'flat' for turtles
  2. -- Made by ryanv09
  3. -- edited by pirateandy (support multiple slots of cobblestone, starting at slot 1)
  4.  
  5. -- Place the turtle at southwest corner of desired surface
  6.  
  7. arg = {...}
  8.  
  9. length = arg[1]
  10. width = arg[2]
  11.  
  12.  
  13. slots = 1
  14. turtle.select(slots)
  15.  
  16. -- Usage
  17. if (length == nil or width == nil) then
  18.   print ("Usage: flat <length> <width>")
  19.   return
  20. end
  21.  
  22.  
  23. -- Checks if the turtle is empty
  24. -- If empty, pauses turtle until last slot has resources
  25. function empty()
  26.   print ("\nchecking slot: ")
  27.   print (slots)
  28.   if (turtle.getItemCount(slots) == 0) then
  29.     if( slots < 17 ) then
  30.       slots = slots + 1
  31.       turtle.select(slots)
  32.     end  
  33.   end
  34. end
  35.  
  36.  
  37. for i=0,(width - 1),1 do
  38.  
  39.   for j=1,(length - 1),1 do
  40.     empty()
  41.     turtle.forward()
  42.     turtle.placeDown()
  43.   end
  44.  
  45.  
  46.   if (i % 2 == 0) then
  47.    
  48.     if (i ~= width - 1) then
  49.       turtle.turnRight()
  50.       turtle.forward()
  51.       turtle.turnRight()
  52.       empty()  
  53.       turtle.placeDown()
  54.     end
  55.   else  
  56.     if (i ~= width - 1) then
  57.       turtle.turnLeft()
  58.       turtle.forward()
  59.       turtle.turnLeft()
  60.       empty()
  61.       turtle.placeDown()
  62.     end
  63.   end
  64.  
  65.   if (j ~= length - 1) then
  66.     empty()
  67.     turtle.placeDown()
  68.   end
  69. end
  70.  
  71. print("\nSurface complete.")
Advertisement
Add Comment
Please, Sign In to add comment