joshuaferr1s

bore.lua

Jun 8th, 2021 (edited)
208
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[
  2.   JoshCorp's Tunnel Bore
  3.  
  4.   Usage: bore [height] [width] [depth]
  5. ]]--
  6.  
  7. os.loadAPI("jcore")
  8.  
  9. local LIGHT = "minecraft:torch"
  10. local BLACKLISTED_ITEMS = {
  11.   "minecraft:cobblestone",
  12.   "minecraft:andesite",
  13.   "minecraft:diorite",
  14.   "minecraft:granite",
  15.   "minecraft:dirt",
  16.   "minecraft:sand",
  17.   "minecraft:sandstone",
  18.   "minecraft:gravel",
  19.   "minecraft:flint",
  20.   "minecraft:obsidian",
  21.   "minecraft:mossy_cobblestone",
  22.   "promenade:blunite",
  23.   "promenade:carbonite",
  24.   "byg:rocky_stone",
  25.   "blockus:limestone",
  26.   "blockus:marble",
  27.   "blockus:bluestone",
  28.   "croptosis:potash",
  29.   "lightstones:lightstone",
  30.   "techreborn:peridot_gem",
  31.   "techreborn:sapphire_gem",
  32.   "mysticalagriculture:inferium_essence"
  33. }
  34.  
  35. local height = 0
  36. local width = 0
  37. local depth = 0
  38.  
  39. if #arg==3 then
  40.   height = tonumber(arg[1])
  41.   width = tonumber(arg[2])
  42.   depth = tonumber(arg[3])
  43.  
  44.   if height%2==0 then
  45.     print("[ERROR] Height must be odd.")
  46.     return
  47.   end
  48.  
  49.   if width%2==0 then
  50.     print("[ERROR] Width must be odd.")
  51.     return
  52.   end
  53. else
  54.   print("Usage: bore [height] [width] [depth]")
  55.   return
  56. end
  57.  
  58. local heightMovement = height-1
  59. local widthMovement = math.floor(width/2)
  60.  
  61. jcore.checkFuel((height*width*depth)+widthMovement+heightMovement+depth)
  62. jcore.checkItemCount(LIGHT, math.ceil(depth/4))
  63.  
  64. jcore.moveLeftAndUp(widthMovement, heightMovement)
  65.  
  66. for d=1, depth+1 do
  67.   print("[INFO] Layer: "..d.."/"..depth)
  68.   jcore.moveForwardAndDig()
  69.  
  70.   for h=1, height do
  71.     if d%2==0 then
  72.       turtle.turnLeft()
  73.     else
  74.       turtle.turnRight()
  75.     end
  76.  
  77.     for w=1, width-1 do
  78.       if d%4==0 and h==2 and w==widthMovement+1 then
  79.         jcore.placeItemDown(LIGHT)
  80.       end
  81.       jcore.moveForwardAndDig()
  82.     end
  83.  
  84.     if h~=height then
  85.       if d%2==0 then
  86.         turtle.turnLeft()
  87.         jcore.moveUpAndDig()
  88.       else
  89.         turtle.turnRight()
  90.         jcore.moveDownAndDig()
  91.       end
  92.     end
  93.   end
  94.  
  95.   if d%2==0 then
  96.     turtle.turnRight()
  97.   else
  98.     turtle.turnLeft()
  99.   end
  100.  
  101.   jcore.removeItems(BLACKLISTED_ITEMS)
  102.   jcore.inventorySort()
  103. end
  104.  
  105. jcore.returnHome3D(heightMovement, widthMovement, depth+1)
  106.  
RAW Paste Data