Advertisement
Guest User

break

a guest
May 31st, 2013
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.52 KB | None | 0 0
  1. function refuel(requireFuel)
  2.  currentFuel = turtle.getFuelLevel()
  3.  
  4.  diffFuel = requireFuel - currentFuel
  5.  
  6.  requireCoal = math.ceil(diffFuel / 80)
  7.  
  8.  cnt = turtle.getItemCount(16)
  9.  
  10.  if cnt < requireCoal then
  11.   print("require coal: " .. requireCoal)
  12.   return false
  13.  end
  14.  
  15.  turtle.select(16)
  16.  turtle.refuel(requireCoal)
  17.  
  18.  return true
  19. end
  20.  
  21. function shiftRight()
  22.  turtle.turnRight()
  23.  turtle.forward()
  24.  turtle.turnLeft()
  25. end
  26.  
  27. function backLeft(width)
  28.  turtle.turnLeft()
  29.  
  30.  for i = 1, width do
  31.   turtle.forward()
  32.  end
  33.  
  34.  turtle.turnRight()
  35. end
  36.  
  37. function backDown(height)
  38.  for i = 1, height do
  39.   turtle.down()
  40.  end
  41. end
  42.  
  43. function getBlock()
  44.  if turtle.detect() then
  45.   for i = 1, 16 do
  46.    if turtle.getItemCount(i) == 0 then
  47.     turtle.dig()
  48.     return i
  49.    end
  50.    
  51.    turtle.select(i)
  52.    
  53.    if turtle.compare() then
  54.     turtle.dig()
  55.     return i
  56.    end
  57.   end
  58.  else
  59.   return 0
  60.  end
  61. end
  62.  
  63. write("Enter Filename\n")
  64. path = read()
  65.  
  66. if path == "" then
  67.  return
  68. end
  69.  
  70. write("Enter Width\n")
  71. width = read()
  72. write("Enter Height\n")
  73. height = read()
  74. write("Enter Depth\n")
  75. depth = read()
  76.  
  77. if refuel(((((width * 2) + 2) * height) + 1) * depth) ~= true then
  78.  return
  79. end
  80.  
  81. f = fs.open(path, "wb")
  82.  
  83. f.write(tonumber(width))
  84. f.write(tonumber(height))
  85. f.write(tonumber(depth))
  86.  
  87. for z = 1, depth do
  88.  for y = 1, height do
  89.   for x = 1, width do
  90.    f.write(getBlock())
  91.    shiftRight()
  92.   end
  93.  
  94.   backLeft(width)
  95.   turtle.up()
  96.  end
  97.  
  98.  backDown(height)
  99.  turtle.forward()
  100. end
  101.  
  102. f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement