Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --The program's purpose is to ask to the user how many block does he wants the turtle to mine in height, length and width
- --everything works fine until the turtle tries to increase is width,
- --instead of turning left or right (it depends if the height is odd or not) then rotate on 180° and finally return to its starting height
- --it doesn't.
- local fLevel = turtle.getFuelLevel()
- term.clear()
- term.setCursorPos(1, 1)
- --Don't mind this, I used this from the wiki
- local ok, err = turtle.refuel(), "Not refuelled\n"
- if ok then
- local new_level = turtle.getFuelLevel()
- print(("Refuelled %d, current level is %d\n"):format(new_level - fLevel, new_level))
- else
- printError(err)
- end
- --Now you can mind my following code
- print("Height to mine : ")
- local height = read()
- print("\nLength to mine : ");
- local length = read()
- print("\nWidth to mine : ")
- local width = read()
- for i = 1, width do
- for j = 1, height do
- for k = 1, length do
- if turtle.detect() then
- turtle.dig()
- end
- turtle.forward()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.up()
- turtle.turnRight()
- turtle.turnRight()
- end
- --les problèmes commencent juste ici / problems start here
- if height % 2 ~= 0 then
- turtle.turnLeft()
- if turtle.detect() then
- turtle.dig()
- end
- turtle.forward()
- turtle.turnLeft()
- else
- turtle.turnRight()
- if turtle.detect() then
- turtle.dig()
- end
- turtle.forward()
- turtle.turnRight()
- end
- for l = 1, height do --reset turtle's height
- if turtle.detectDown() then
- turtle.digDown()
- end
- turtle.down()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement