Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- borer.lua
- -- gaat een 9 breed op 9 hoog tunnel graven, zolang hij torches in slot 1 heeft om te plaatsen.
- -- zal iedere 8 blocks een torch zetten en zijn inventory legen, door items in de blacklist te yeeten en de rest te storen in een chest
- -- Primen door:
- -- 64 torches in slot 1
- -- minstens 10 chests in slot 2
- -- een empty bucket in slot 3
- -- kies jouw 9x9 vlak en maak een gat in de linkeronderhoek op ooghoogte
- -- plaats de borer hierin, voorkant gericht op de richting van de tunnel
- -- execute het script
- -- HELPERS
- function contains(list, x)
- for _, v in pairs(list) do
- if v == x then return true end
- end
- return false
- end
- function safeForward()
- succ = turtle.forward()
- while not succ do
- turtle.dig()
- succ = turtle.forward()
- end
- end
- function safeDig()
- local bool, block = turtle.inspect()
- if bool then
- if block.name == "minecraft:lava" then
- turtle.select(3)
- turtle.place()
- turtle.refuel()
- turtle.select(1)
- else
- turtle.dig()
- end
- end
- end
- function safeDigDown()
- local bool, block = turtle.inspectDown()
- if bool then
- if block.name == "minecraft:lava" then
- turtle.select(3)
- turtle.placeDown()
- turtle.refuel()
- turtle.select(1)
- else
- turtle.digDown()
- end
- end
- end
- function safeDigUp()
- local bool, block = turtle.inspectUp()
- if bool then
- if block.name == "minecraft:lava" then
- turtle.select(3)
- turtle.placeUp()
- turtle.refuel()
- turtle.select(1)
- else
- turtle.digUp()
- end
- end
- end
- function lavaPresent()
- isPresent = false
- local boolfront, blockfront = turtle.inspect()
- if boolfront then
- if blockfront.name == "minecraft:lava" or blockfront.name == "minecraft:flowing_lava" then
- isPresent = true
- end
- end
- local boolup, blockup = turtle.inspectUp()
- if boolup then
- if blockup.name == "minecraft:lava" or blockup.name == "minecraft:flowing_lava" then
- isPresent = true
- end
- end
- local booldown, blockdown = turtle.inspectDown()
- if booldown then
- if blockdown.name == "minecraft:lava" or blockdown.name == "minecraft:flowing_lava" then
- isPresent = true
- end
- end
- return isPresent
- end
- -- GLOBALS
- blacklist = {
- "minecraft:cobblestone",
- "minecraft:andesite",
- "minecraft:diorite",
- "minecraft:granite",
- "minecraft:dirt",
- "minecraft:gravel"
- }
- -- DIGGER
- function digHorizontalSlice(sliceidx, onFloor)
- for i=2,9 do -- horizontal slice
- turtle.dig()
- safeForward()
- safeDigUp()
- safeDigDown()
- if onFloor then
- if (sliceidx == 1 and i == 2) or (sliceidx == 2 and i == 4) or (sliceidx == 4 and i == 7) then
- turtle.placeDown()
- end
- end
- end
- end
- -- if torch is true, place a torch
- function goThreeUp()
- turtle.up()
- safeDigUp()
- turtle.up()
- safeDigUp()
- turtle.up()
- safeDigUp()
- turtle.turnRight()
- turtle.turnRight()
- end
- function goThreeDown()
- turtle.turnRight()
- turtle.turnRight()
- turtle.down()
- safeDigDown()
- turtle.down()
- safeDigDown()
- turtle.down()
- safeDigDown()
- end
- function digSlice(i)
- turtle.turnRight()
- safeDigUp()
- safeDigDown()
- digHorizontalSlice(i, true)
- goThreeUp()
- digHorizontalSlice(i, false)
- goThreeUp()
- digHorizontalSlice(i, false)
- turtle.turnLeft()
- turtle.dig()
- safeForward()
- turtle.turnLeft()
- safeDigUp()
- safeDigDown()
- digHorizontalSlice(false)
- goThreeDown()
- digHorizontalSlice(false)
- goThreeDown()
- digHorizontalSlice(false)
- end
- function digChunk()
- for i=1,4 do
- digSlice(i)
- dumpBlacklist()
- turtle.turnRight()
- turtle.dig()
- safeForward()
- safeDigUp()
- safeDigDown()
- end
- end
- -- INVENTORY
- function dumpBlacklist()
- for i=4,16 do
- turtle.select(i)
- local item = turtle.getItemDetail()
- if item ~= nil then
- if contains(blacklist, item.name) then -- trash
- turtle.dropDown(item.count)
- end
- end
- end
- turtle.select(1)
- end
- function clearInventory()
- dumpBlacklist()
- backpackFull = False
- for i = 4,16 do
- if turtle.getItemCount(i) >= 60 then
- backpackFull = true
- end
- end
- isPresent = lavaPresent()
- if backpackFull and not isPresent then
- turtle.back()
- turtle.select(2) -- chest
- if turtle.placeDown() then
- print("placed Chest at chunk:")
- print(chunkCounter)
- if backpackFull then
- for i=4,16 do -- clear junk
- turtle.select(i)
- local item = turtle.getItemDetail()
- if item ~= nil then
- if item.name == "minecraft:coal" and turtle.getFuelLevel() < 1000 then --refuel
- turtle.refuel(item.count-1)
- else -- keep 1 in inventory
- turtle.dropDown(item.count)
- end
- end
- end
- end
- end
- turtle.select(1)
- safeForward()
- end
- end
- -- MAIN
- chunkCounter = 0
- while turtle.getItemCount(1) > 0 do
- digChunk()
- chunkCounter = chunkCounter + 1
- clearInventory(chunkCounter)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement