t8rt0t

mine.lua

Mar 13th, 2024 (edited)
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.71 KB | None | 0 0
  1. local args = {...}
  2. if not args or not args[1] then
  3.     print("Valid Arguments:")
  4.     print("tunnel <width> <height> <depth>")
  5.     print("stairs <width> <height> <depth>")
  6.     print("mineshaft <depth> <count> <spacing>")
  7.     print("pattern mode count pattern1 <pattern2> <pattern3> ...")
  8.     return
  9. end
  10. refuel.refuel()
  11. term.clear()
  12. if string.lower(args[1]) == "pattern" then
  13.     local patterns = {}
  14.     for i=4,#args do
  15.         print(args[i])
  16.         local a,b,c,d,e,f = pattern.loadPattern(args[i])
  17.         if not a then error(b) end
  18.         table.insert(patterns,{a=a,b=b,c=c,d=d,e=e,f=f})
  19.     end
  20.     if #patterns <= 0 then error("No specified patterns") end
  21.     local count = args[3]
  22.     local mode = args[2]
  23.     if not tonumber(count) then count = #patterns else count = tonumber(count) end
  24.     for i=0,count-1 do
  25.         local index = i%(#patterns)+1
  26.         if index <= 0 then index = #patterns end
  27.         local p = patterns[index]
  28.         --why is table unpack dumb
  29.         success,turtleData = pattern.mine(p.a,p.b,p.c,p.d,p.e,p.f,mode)
  30.         while turtleData.horizRot ~= 0 do
  31.             turt.turnLeft()
  32.             turtleData.horizRot = (turtleData.horizRot-1)%4
  33.         end
  34.         if not success then error("pattern mining failed") end
  35.     end
  36.     term.clear()
  37.     term.setCursorPos(1,1)
  38.     term.setBackgroundColor(colors.black)
  39.     term.setTextColor(colors.white)
  40.     stats.printStat()
  41.     return
  42. end
  43. args[2],args[3],args[4] = tonumber(args[2]),tonumber(args[3]),tonumber(args[4])
  44. if string.lower(args[1]) == "tunnel" then
  45.     local cost = (args[2] or 3)*(args[3] or 3) * (args[4] or 30)
  46.     if cost > turtle.getFuelLevel() then error("Not enough fuel to make the trip") end
  47.     mine.mineTunnel(args[2],args[3],args[4])
  48. elseif string.lower(args[1]) == "stairs" then
  49.     local cost = (args[2] or 3) * (args[3] or 6) * (args[4] or 30)
  50.     if cost > turtle.getFuelLevel() then error("Not enough fuel to complete task") end
  51.     mine.mineDeprecatedStairs(args[2],args[3],args[4])
  52. elseif string.lower(args[1]) == "mineshaft" then
  53.     local cost = ((args[2] or 45) + (args[4] or 3))*2*(args[3] or 10)
  54.     if cost > turtle.getFuelLevel() then error("Not enough fuel to complete task") end
  55.     args[5] = args[5] == "true"
  56.     mine.createMiningTunnels(args[2],args[3],args[4],args[5])
  57. end
  58. --mine.miningTunnel(45,4,3)
  59. --mine.stairs(1,6,30)
  60. --print("test2")
  61. local success,msg = turt.storeItems()
  62. if not success then
  63.     term.setTextColor(colors.red)
  64.     print(msg)
  65.     term.setTextColor(colors.white)
  66. else
  67.     stats.printStat()
  68. end
  69. --print("Blocks Dug:",stats.read("Amount Dug") or 0)
  70. --print("Times Moved:",stats.read("Times Moved") or 0)
  71. --print("Items Dropped:",stats,read("Items Dropped") or 0)
  72.  
Advertisement
Add Comment
Please, Sign In to add comment