Advertisement
psychedelixx

Minecraft Turtle: Walls

Mar 30th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[
  2.     2014 (c) psychedelixx
  3.     Minecraft Turtle: Walls
  4.     2014-03-,0
  5.  
  6.     Builds a wall e.g. for a house
  7.  
  8.     Usage:
  9.     - use turtle and type "label set <name>"
  10.       (to give your turtle an unique name so it remembers its programs)
  11.     - type "pastebin get RVrtjU1f walls"
  12.     - type "walls <width> <length> <height>"
  13. --]]
  14.  
  15. slot = 0
  16.  
  17. function move()
  18.     if turtle.getItemCount(slot%16+1)==0 then
  19.     slot = slot+1
  20.     turtle.select(slot%16+1)        
  21.     end
  22.     turtle.placeDown()
  23.     turtle.dig()
  24.     turtle.forward()
  25. end
  26.  
  27. local args = { ... }
  28. if #args < 3 then
  29.     print( "Usage: walls <width> <length> <height>" )
  30.     error()
  31. end
  32. width = tonumber(args[1])
  33. length = tonumber(args[2])
  34. height = tonumber(args[3])
  35.  
  36. if turtle.getFuelLevel() < (2*width + 2*length) * height then
  37.     print("I need " .. (2*width + 2*length) * height - turtle.getFuelLevel() .. " fuel.")
  38. else
  39.     print("======== 2014 (c) psychedelixx ========")
  40.     print("Let's go!")
  41.  
  42.     turtle.up()
  43.     repeat
  44.         l = 1
  45.         while l < length do
  46.             move()
  47.             l = l + 1
  48.         end
  49.         turtle.turnRight()
  50.  
  51.         w = 1
  52.         while w < width do
  53.             move()
  54.             w = w + 1
  55.         end
  56.         turtle.turnRight()
  57.  
  58.         l = 1
  59.         while l < length do
  60.             move()
  61.             l = l + 1
  62.         end
  63.         turtle.turnRight()
  64.  
  65.         w = 1
  66.         while w < width do
  67.             move()
  68.             w = w + 1
  69.         end
  70.         turtle.up()
  71.         turtle.turnRight()
  72.  
  73.         height = height - 1
  74.     until height<=0
  75. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement