Guest User

Quarry script

a guest
Jan 10th, 2013
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.56 KB | None | 0 0
  1. local tArgs = { ... }
  2. local w = tArgs[1] or 5
  3. local h = tArgs[2] or 5
  4. local d = tArgs[3] or 5
  5. if type(w) ~= "number" then w = tonumber(w) end
  6. if type(h) ~= "number" then h = tonumber(h) end
  7. if type(d) ~= "number" then d = tonumber(d) end
  8. print("Quarry " .. w .. "x" .. h .. " to depth 3x" .. d)
  9.  
  10. local home = {
  11.     _x = x,
  12.     _y = y,
  13.     _z = z,
  14.     _r = r
  15. }
  16. local mark = {
  17.     _x = x,
  18.     _y = y,
  19.     _z = z,
  20.     _r = r
  21. }
  22.  
  23. function dump(resumeDig)
  24.     print("going home")
  25.     doSend("dumping")
  26.     if resumeDig == nil then resumeDig = false end
  27.     if resumeDig then
  28.         mark._x = x
  29.         mark._y = y
  30.         mark._z = z
  31.         mark._r = r
  32.     end
  33.     goTo(home._x, home._y + 1, home._z, (home._r + 2) % 4)
  34.     dig = {false, false, false}
  35.     goFwd(1)
  36.     print("dumping items")
  37.     for i = 1, 16 do
  38.         turtle.select(i)
  39.         turtle.drop()
  40.     end
  41.     goBack(1)
  42.     dig = {true, true, true}
  43.     if resumeDig then
  44.         doSend("mining")
  45.         goTo(mark._x, mark._y, mark._z, mark._r)
  46.     end
  47. end
  48.  
  49. function checkFull()
  50.     for slot = 1, 16 do
  51.         if turtle.getItemCount(slot) == 0 then return false end
  52.     end
  53.     return true
  54. end
  55.  
  56. print("Home at (" .. home._x .. "," .. home._y .. "," .. home._z .. "," .. home._r .. ")")
  57. doSend("mining")
  58. dig = {true, true, true}
  59. for j = 1, d do
  60.     if j == 1 then goDown(2) else goDown(3) end
  61.     turtle.digDown()
  62.     for i = 1, w do
  63.         goFwd(h - 1)
  64.         if i < w then
  65.             if i % 2 == 1 then
  66.                 turnRight()
  67.                 goFwd(1)
  68.                 turnRight()
  69.             else
  70.                 turnLeft()
  71.                 goFwd(1)
  72.                 turnLeft()
  73.             end
  74.         else
  75.             turnRight()
  76.             turnRight()
  77.         end
  78.         if checkFull() then dump(true) end
  79.     end
  80. end
  81.  
  82. print("Done!")
Advertisement
Add Comment
Please, Sign In to add comment