Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- - side: 2 for right, left otherwise
- - numTun(nel): number of small mining tunnels on side
- - lenTun(nel): length of each mining tunnel
- - bLava: allow the collection of lava
- - bAllLava: Emptys every lava lake it comes across
- ]]
- side, numTun, lenTun, bLava, bAllLava = ...
- stringtoboolean = { ["true"] = true, ["false"] = false }
- --side for the mining tunnels
- tunnelSide = "left"
- if side then
- if tonumber(side) == 2 then
- tunnelSide = "right"
- end
- end
- --number of tunnels (2 blocks in between)
- numTunnels = 1
- if numTun then
- numTunnels = tonumber(numTun)
- end
- --length of single tunnel
- lenTunnel = 3
- if lenTun then
- lenTunnel = tonumber(lenTun)
- end
- --uses or destroys bordering lava
- if bLava then
- bLava = stringtoboolean[bLava]
- else
- bLava = false
- end
- --uses or destroys all connected lava
- if bAllLava then
- bAllLava = stringtoboolean[bAllLava]
- else
- bAllLava = false
- end
- --Counter for found lava springs
- lavaCnt = {0}
- blocksToMine = {
- "minecraft:oak_log", "minecraft:oak_leaves",
- "minecraft:spruce_log", "minecraft:spruce_leaves",
- "minecraft:birch_log", "minecraft:birch_leaves",
- "minecraft:jungle_log", "minecraft:jungle_leaves",
- "minecraft:acacia_log", "minecraft:acacia_leaves",
- "minecraft:dark_oak_log", "minecraft:dark_oak_leaves",
- "minecraft:mangrove_log", "minecraft:mangrove_leaves",
- "minecraft:cherry_log", "minecraft:cherry_leaves",
- "minecraft:pale_oak_log", "minecraft:pale_oak_leaves",
- "minecraft:crimson_stem", "minecraft:azalea_leaves",
- "minecraft:warped_stem", "minecraft:flowering_azalea_leaves",
- "minecraft:nether_wart_block", "minecraft:warped_wart_block",
- "minecraft:shroomlight"
- }
- notDroppedBlocks = {
- "minecraft:chest", "minecraft:torch",
- "minecraft:bucket", "minecraft:lava_bucket"
- }
- lavaArray = {"minecraft:lava"}
- bucketList = {"minecraft:bucket", "minecraft:lava_bucket"}
- local move = require("move")
- local inspect = require("inspect")
- local collectLava = require("collectLava")
- local dropAll = require("dropAll")
- -- turns into tunnel or back out in starting direction
- function takeTurn()
- if tunnelSide == "left" then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- end
- -- collects all valuable blcoks that are connected to start block (+Lava collection/destruction possible)
- function collectAllValuables()
- local bLocLava = bLava
- if not collectLava.selectBucket() then
- bLocLava = false
- end
- if inspect.Down(blocksToMine) then
- move.Down()
- collectAllValuables()
- move.Up()
- elseif inspect.Down(lavaArray) and bLocLava then
- collectLava.Bottom(lavaCnt)
- if bAllLava then
- move.Down()
- collectAllValuables()
- move.Up()
- end
- end
- if inspect.Forward(blocksToMine) then
- move.Forward()
- collectAllValuables()
- move.turnBack()
- move.Forward()
- move.turnBack()
- elseif inspect.Forward(lavaArray) and bLocLava then
- collectLava.Front(lavaCnt)
- if bAllLava then
- move.Forward()
- collectAllValuables()
- move.turnBack()
- move.Forward()
- move.turnBack()
- end
- end
- turtle.turnRight() -- right
- if inspect.Forward(blocksToMine) then
- move.Forward()
- collectAllValuables()
- move.turnBack()
- move.Forward()
- move.turnBack()
- elseif inspect.Forward(lavaArray) and bLocLava then
- collectLava.Front(lavaCnt)
- if bAllLava then
- move.Forward()
- collectAllValuables()
- move.turnBack()
- move.Forward()
- move.turnBack()
- end
- end
- turtle.turnRight() -- back
- if inspect.Forward(blocksToMine) then
- move.Forward()
- collectAllValuables()
- move.turnBack()
- move.Forward()
- move.turnBack()
- elseif inspect.Forward(lavaArray) and bLocLava then
- collectLava.Front(lavaCnt)
- if bAllLava then
- move.Forward()
- collectAllValuables()
- move.turnBack()
- move.Forward()
- move.turnBack()
- end
- end
- turtle.turnRight() -- left
- if inspect.Forward(blocksToMine) then
- move.Forward()
- collectAllValuables()
- move.turnBack()
- move.Forward()
- move.turnBack()
- elseif inspect.Forward(lavaArray) and bLocLava then
- collectLava.Front(lavaCnt)
- if bAllLava then
- move.Forward()
- collectAllValuables()
- move.turnBack()
- move.Forward()
- move.turnBack()
- end
- end
- turtle.turnRight() -- forward
- if inspect.Up(blocksToMine) then
- move.Up()
- collectAllValuables()
- move.Down()
- elseif inspect.Up(lavaArray) and bLocLava then
- collectLava.Top(lavaCnt)
- if bAllLava then
- move.Up()
- collectAllValuables()
- move.Down()
- end
- end
- return true
- end
- -- places chest on top of turtle
- function placeChest()
- for i = 1, 16, 1 do
- turtle.select(i)
- itemDetail = turtle.getItemDetail()
- if itemDetail then
- if itemDetail.name == "minecraft:chest" then
- move.Up()
- move.Up()
- move.Down()
- move.Down()
- turtle.placeUp()
- return true
- end
- end
- end
- if bLava then
- if not (lavaCnt[1] == 0) then
- print(tostring(lavaCnt[1]).." Lavablocks were collected/destroyed")
- lavaCnt[1] = 0
- end
- end
- return false
- end
- -- mines one tunnel and comes back out
- function mineTunnel (remainingLength)
- if not (remainingLength == 0) then
- move.Forward()
- collectAllValuables()
- move.Up()
- collectAllValuables()
- move.Down()
- mineTunnel(remainingLength - 1)
- move.Forward()
- else
- move.turnBack()
- end
- end
- -- Digs and mines all tunnels
- function runTunnelMiner()
- for i=1, numTunnels, 1 do
- takeTurn()
- mineTunnel(lenTunnel)
- if placeChest() then
- dropAll.Up(notDroppedBlocks)
- end
- takeTurn()
- if not (i == numTunnels) then
- move.Forward()
- move.Forward()
- move.Forward()
- end
- end
- end
- runTunnelMiner()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement