SHARE
TWEET

Untitled

a guest Feb 20th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Quarry Capper
  2. --by BrknSoul, 07-Oct-2012
  3.  
  4. --Get input
  5. local args={ ... }
  6.  
  7. --Set variables
  8. local x=tonumber(args[1])
  9. local z=tonumber(args[2])-1
  10. local bigger
  11. local loopcheck=0
  12. local stacks = math.floor(x*(z+1)/64)
  13. local leftover = x*(z+1)-stacks*64
  14. --assign the biggest variable for the while loop later
  15. if x==z then
  16.   bigger="X"
  17. else
  18.   if x > z then
  19.     bigger="X"
  20.   else
  21.     bigger="Z"
  22.   end
  23. end
  24.  
  25. --Bit o' help
  26. if #args < 2 then
  27.   print("Usage: cap <x> <z>")
  28.   return
  29. end
  30.  
  31. --Information
  32. term.clear()
  33. term.setCursorPos(1,1)
  34. print("About to fill in a "..x.." by "..(z+1).." area!")
  35. print("I'll need "..x*(z+1).." blocks.")
  36. print("That's "..stacks.." stacks, and "..leftover.." blocks")
  37. print("Hit [SPACE] when ready!")
  38. while true do
  39.   local ev,p1=os.pullEvent("key")
  40.   if tonumber(p1) == 57 then
  41.     break
  42.   end
  43. end
  44. print("Okey dokey! Cappin' this area!")
  45.  
  46.  
  47. --Item Checker
  48. function itemcheck()
  49.   for s=1,16 do
  50.     if turtle.getItemCount(s) > 0 then
  51.       turtle.select(s)
  52.       return
  53.     end
  54.   end
  55.   print("Nothing to place! Feed me blocks!")
  56.   sleep(1.0)
  57.   loopcheck=loopcheck+1
  58.   if loopcheck==30 then
  59.     print("No blocks for 30 seconds. Terminating.")
  60.     die()
  61.   else
  62.     itemcheck()
  63.   end
  64. end
  65.  
  66. --Place a block, move forward on the X axis
  67. function placex()
  68.   for i=1,x do
  69.     loopcheck=0
  70.     itemcheck()
  71.     turtle.forward()
  72.     if not turtle.detectDown() then
  73.       turtle.placeDown()
  74.     end
  75.   end
  76.   x=x-1
  77.   turtle.turnRight()
  78. end
  79.  
  80. --Place a block, move forward on the Z axis
  81. function placez()
  82.   for i=1,z do
  83.     loopcheck=0
  84.     itemcheck()
  85.     turtle.forward()
  86.     if not turtle.detectDown() then
  87.       turtle.placeDown()
  88.     end
  89.   end
  90.   z=z-1
  91.   turtle.turnRight()
  92. end
  93.  
  94. --Keep placing blocks until finished
  95. if bigger=="X" then
  96.   while x>0 do
  97.     placex()
  98.     placez()
  99.   end
  100. else
  101.   while z>0 do
  102.     placex()
  103.     placez()
  104.   end
  105. end
  106.  
  107. --DIE DIE DIE ;-)
  108. function die()
  109. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top