Advertisement
Alptraum3000

k.floor

Oct 6th, 2015
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.42 KB | None | 0 0
  1. -- Turle Script
  2. -- Floor Builder - floor will extend forward and to the left in the current facing direction
  3. -- Apltraum3000 13.06.2014
  4.  
  5. -- Parameter
  6. maxLength = 6
  7. maxWidth = 6
  8. materialSlot = 2 -- first slot used for fill material. all following will be used as well
  9.  
  10. -- internal vars
  11. curPosL = 1
  12. curPosW = 1
  13. curDirection = 1
  14. noHindrance = true
  15.  
  16. function checkL()
  17.     if( curDirection == 1) then
  18.         return curPosL<maxLength
  19.     else
  20.         return curPosL>1
  21.     end
  22. end
  23.  
  24. -- go and place blocks underneath
  25. turtle.select(materialSlot)
  26. while (curPosW<maxWidth and noHindrance and turtle.getItemCount(materialSlot)>0) do
  27.     -- move
  28.     while ( checkL() and turtle.getItemCount(materialSlot)>0 and turtle.forward() ) do
  29.         turtle.placeDown()
  30.         if ( turtle.getItemCount(materialSlot) == 0 ) then
  31.             if (materialSlot < 16) then
  32.                 materialSlot = materialSlot + 1
  33.                 turtle.select(materialSlot)
  34.             end
  35.         end
  36.         curPosL = curPosL + curDirection
  37.     end
  38.     -- turn
  39.     if curDirection == 1 then
  40.         turtle.turnLeft()
  41.         noHindrance = turtle.forward()
  42.         turtle.turnLeft()
  43.     else
  44.         turtle.turnRight()
  45.         noHindrance = turtle.forward()
  46.         turtle.turnRight()
  47.     end
  48.     if noHindrance then
  49.         curPosW = curPosW + 1
  50.     end
  51.     curDirection = (-1)*curDirection
  52. end
  53. -- return width
  54. if curDirection == 1 then
  55.     turtle.turnRight()
  56. else
  57.     turtle.turnLeft()
  58. end
  59. for i=curPosW,1,-1 do
  60.     turtle.forward()
  61. end
  62. -- return length
  63. turtle.turnRight()
  64. for i=curPosL,1,-1 do
  65.     turtle.forward()
  66. end
  67. turtle.turnRight()
  68. turtle.turnRight()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement