Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Un programme de detection de lapis
- local heigth = 14 --distance to level 14
- local length = 64*16/3-1 --length of the tunnel
- local position = 0
- local detected = false
- local orePos = {x=0, y=0}
- print("Enter the heigth to level 14 :")
- heigth = read()
- function dw(step)
- for i=1, step do
- turtle.digDown()
- turtle.down()
- end
- end
- function fw(step)
- for i=1, step do
- print("Inspecting front block\n")
- local isBlock, data = turtle.inspect()
- if isBlock then
- if data.name == "minecraft:lapisore" then
- detected = true
- orePos.x = position+1
- orePos.y = 14
- return detected
- end
- else
- turtle.dig()
- end
- end
- print("Inspecting down block\n")
- isBlock, data = turtle.inspectDown()
- if isBlock then
- if data.name == "minecraft:lapisore" then
- detected = true
- orePos.x = position
- orePos.y = 13
- return detected
- end
- else
- turtle.digDown()
- end
- end
- print("Inspecting up block\n")
- isBlock, data = turtle.inspectUp()
- if isBlock then
- if data.name == "minecraft:lapisore" then
- detected = true
- orePos.x = position
- orePos.y = 15
- return detected
- end
- end
- turtle.turnLeft()
- print("Inspecting left block\n")
- isBlock, data = turtle.inspect()
- turtle.turnRight()
- if isBlock then
- if data.name == "minecraft:lapisore" then
- detected = true
- orePos.x = position
- orePos.y = 14
- return detected
- end
- end
- turtle.turnRight()
- print("Inspecting right block\n")
- isBlock, data = turtle.inspect()
- turtle.turnLeft()
- if isBlock then
- if data.name == "minecraft:lapisore" then
- detected = true
- orePos.x = position
- orePos.y = 14
- return detected
- end
- end
- turtle.forward()
- position = position + 1
- if position%12 == 0 then
- print("Placing a torch\n")
- turtle.select(1)
- turtle.turnLeft()
- turtle.place()
- turtle.turnRight()
- end
- end
- end
- dw(heigth)
- fw(length)
- if detected then
- f = fs.open("ore", "w")
- f.write("Ore position :"..orePos.x.." Ore heigth :"..orePos.y)
- f.close()
- term.clear()
- print("Ore position :"..orePos.x.." Ore heigth :"..orePos.y)
- end
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1, position do
- turtle.forward()
- end
- for u=1, heigth do
- turtle.up()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement