Advertisement
Guest User

wall

a guest
Apr 8th, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.34 KB | None | 0 0
  1. local argv = { ... }
  2.  
  3. argv[1] = tonumber(argv[1])
  4. argv[2] = tonumber(argv[2])
  5.  
  6. if argv[1] < 0 or argv[2] < 0 or argv[1] == null then
  7.   print("You must specify a length and width.")
  8.   sleep(5)
  9.   restart()
  10. end
  11.  
  12. function fw()
  13.   while not turtle.forward() do
  14.     sleep(0)
  15.     turtle.dig()
  16.   end
  17. end
  18.  
  19. function up()
  20.   while not turtle.up() do
  21.     sleep(0)
  22.     turtle.digUp()
  23.   end
  24. end
  25.  
  26. function pd()
  27.   while turtle.placeDown() == false do
  28.     sleep(0)
  29.     if turtle.select(turtle.getSelectedSlot() + 1) then
  30.     else
  31.       print("Waiting for blocks...")
  32.       turtle.select(1)
  33.       while turtle.getItemCount() < 1 do
  34.         sleep(5)
  35.       end
  36.     end
  37.   end
  38. end      
  39.    
  40.  
  41. print("Building a wall of size " .. argv[1] .. " by " .. argv[2] .. ".")
  42.  
  43. function buildRow()
  44.   up()
  45.   for j = 1,argv[1],2 do
  46.     pd()
  47.     fw()
  48.     pd()
  49.     fw()
  50.   end
  51.   if argv[1] % 2 == 1 then
  52.     pd()
  53.     fw()
  54.   end
  55.   turtle.turnRight()
  56.   turtle.turnRight()
  57.   pd()
  58. end
  59.  
  60. for i = 1,argv[2],2 do
  61.   buildRow()
  62. end
  63.  
  64. if argv[2] == 1 then
  65.   buildRow()
  66.   for t = 1,argv[1] do
  67.     fw()
  68.   end
  69.   for u = 1,argv[2] do
  70.     turtle.down()
  71.   end
  72. else
  73.   turtle.turnRight()
  74.   turtle.turnRight()
  75.   fw()
  76.   for v = 1,argv[2] do
  77.     turtle.down()
  78.   end
  79. end
  80.  
  81. print("Done building!")
  82. print("Congratulations on your presidency, Trump.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement