Advertisement
Guest User

fence

a guest
Dec 18th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.79 KB | None | 0 0
  1. local tArgs = {...}
  2. --Movement and Placement of Fence
  3. function place(size)
  4.   local num = size
  5.   repeat
  6.   turtle.place(1)
  7.   turnAround()
  8.   look()
  9.   turnAround()
  10.   turtle.back()
  11.   sleep(1)
  12.   num = num - 1
  13.   until num == 0
  14. end
  15.  
  16. function turnAround()
  17.   turtle.turnLeft()
  18.   turtle.turnLeft()
  19. end
  20.  
  21. function look()
  22.   if turtle.detect() then
  23.     turtle.dig()
  24.   end
  25. end
  26.  
  27. function lastPlace()
  28.   turtle.place(1)
  29.   turtle.turnLeft()
  30.   look()
  31.   turnAround()
  32.   turtle.back()
  33. end
  34.  
  35. function lastFence()
  36.   turtle.turnRight()
  37.   sleep(1)
  38.   look()
  39.   sleep(1)
  40.   turnAround()
  41.   turtle.back()
  42.   turtle.place(1)
  43. end
  44. --Main Program
  45. local n = tonumber(tArgs[1])
  46. for i=1,3,1 do
  47. turtle.select(i)
  48. place(n-1)
  49. sleep(1)
  50. lastPlace()
  51. sleep(1)
  52. end
  53. turtle.select(4)
  54. place(n-2)
  55. lastFence()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement