Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 1st, 2012  |  syntax: Lua  |  size: 0.95 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. tArgs = {...}
  2.  
  3. nSel = 1
  4.  
  5. turtle.select(nSel)
  6.  
  7. local function printUsage()
  8.     print("Usages:")
  9.     print("build <length>")
  10.     print("build <length> <height>")
  11. end
  12.  
  13. local nLength = tonumber(tArgs[1])
  14. local nHeight = tonumber(tArgs[2])
  15.  
  16. if #tArgs > 2 or #tArgs < 1 or nLength == nil then
  17.         printUsage()
  18.         return
  19. end
  20.  
  21. if nHeight == nil then
  22.         nHeight = 1
  23. end
  24.  
  25. local function checkSlot()
  26.         while getItemCount(nSel) == 0 do
  27.                 nSel = nSel + 1
  28.                 if nSel > 9 then
  29.                         return 0
  30.                 end
  31.                 turtle.select(nSel)
  32.         end
  33.         return 1
  34. end
  35.  
  36. local function buildLength()
  37.         x = 0
  38.         ret = 1
  39.         while x < nLength do
  40.                 if checkSlot() == 0 then
  41.                         return 0
  42.                 end
  43.                 turtle.place()
  44.                 turtle.back()
  45.                 x = x + 1
  46.         end
  47.         return 1
  48. end
  49.  
  50. y = 0
  51. while y < nHeight do
  52.         if buildLength() == 0 then
  53.                 print("Out of blocks")
  54.                 return
  55.         end
  56.         turtle.turnRight()
  57.         turtle.turnRight()
  58.         turtle.up()
  59.         turtle.back()
  60.         turtle.back()
  61.         y = y + 1
  62. end
  63.  
  64. print("Done building!")