Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --constants
- local lava = "minecraft:lava"
- local flowingLava = "minecraft:flowing_lava"
- local water = "minecraft:water"
- local flowingWater = "minecraft:flowing_water"
- local stone = "minecraft:stone"
- local iron = "minecraft:iron_ore"
- local coal = "minecraft:coal_ore"
- local redstone = "minecraft:redstone_ore"
- local diamond = "minecraft:diamond_ore"
- local ores = {iron,coal,redstone,diamond}
- local fluids = {lava,flowingLava,water,flowingWater}
- --functions
- --printList
- local function printList(list)
- for _,item in pairs(list) do
- print(item)
- end
- end
- -- check for a block in front, down and up
- -- ex (2, "front")
- local function findBlock(blocksTypes, direction)
- local foundBlock = false
- -- check directiom
- if direction == "front" then
- succes, data = turtle.inspect()
- elseif direction == "up" then
- succes, data = turtle.inspectUp()
- elseif direction == "down" then
- succes, data = turtle.inspectDown()
- else
- error("function: findBlock() needs direction")
- end
- -- find block
- local type = 0
- for _,blocks in pairs(blocksTypes) do
- type = type + 1
- for _,block in pairs(blocks) do
- if succes and data.name == block then
- foundBlock = type
- elseif not succes then
- foundBlock = -1
- end
- end
- end
- print("BlockID",direction,":", data.name)
- return foundBlock
- end
- --shaftCreate
- -- mines above and forward
- local function tunnelCreate()
- local gotFuel = true
- turtle.digUp()
- turtle.dig()
- succes, reason = turtle.forward()
- if succes == false then
- print("Turtle didn't move")
- if reason == "Out of fuel" then
- gotFuel = false
- elseif reason == "Movement obstructed" then
- print("tumnel3(): Movement obstructed")
- end
- end
- return gotFuel
- end
- --main
- local args = {...}
- local len = args[1]
- local foundBlockDown = 0
- for i = 1,len do
- if not tunnelCreate() then
- turtle.refuel()
- end
- foundBlockDown = findBlock({ores,fluids,},"down")
- if foundBlockDown == 1 then
- print("found a ore")
- elseif foundBlockDown == 2 then
- turtle.suckDown()
- turtle.placeDown(1)
- print("found a fluid")
- elseif foundBlockDown == -1 then
- print("found a gap")
- turtle.placeDown(1)
- end
- foundBlockDown = 0
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement