Advertisement
BigSHinyToys

Simple mining program

May 4th, 2013
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.08 KB | None | 0 0
  1. --[[
  2.         mine program
  3.         by Big SHiny Toys
  4. ]]--
  5.  
  6. local function getNumber(title)
  7.     local nOut
  8.     repeat
  9.         write(title)
  10.         nOut = tonumber(read())
  11.     until nOut and nOut > 0
  12.     return nOut
  13. end
  14.  
  15. local ver = 0.9
  16. local tArgs = {...}
  17.  
  18. print("\n ---- Basic miner ----\n\tby  : BigSHinyToys\n\tver : "..tostring(ver).."\n")
  19.  
  20. local depth = tArgs[1] and tonumber(tArgs[1]) or getNumber("Depth  : ")
  21. local length = tArgs[2] and tonumber(tArgs[2]) or getNumber("Length : ")
  22. local width = tArgs[3] and tonumber(tArgs[3]) or getNumber("Width  : ")
  23.  
  24. turtle.turnLeft()
  25.  
  26. local function force(dig,move,atk)
  27.     turtle[dig]()
  28.     while not turtle[move]() do
  29.         turtle[move]()
  30.         turtle[atk]()
  31.         sleep(0.5)
  32.     end
  33. end
  34.  
  35. local right = true
  36. for z = 1,depth do
  37.     force("digDown","down","attackDown")
  38.     right = not right
  39.     for y = 1,length do
  40.         right = not right
  41.         local _ = right and turtle.turnRight() or turtle.turnLeft()
  42.         _ = y == 1 or force("dig","forward","attack")
  43.         _ = right and turtle.turnRight() or turtle.turnLeft()
  44.         for x = 1,width - 1 do
  45.             force("dig","forward","attack")
  46.         end
  47.     end
  48. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement