Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local pArgs = { ... }
- local i = 0
- local size = 0
- function error1()
- print("Usage: obsidian <path> <swing>")
- print("path, 0 - endless movement")
- print("swing, left = l or right = r")
- end
- if #pArgs < 2 then
- error1()
- return
- end
- local statis = {0,0,0,0}
- local coor = {["x"] = 0, ["y"] = 0, ["c"] = 5} --X, Y, Course
- local size = tonumber( pArgs[1] )
- if pArgs[2] == "l" then
- i = 1
- else
- if pArgs[2] == "r" then
- i = 2
- else
- error1()
- return
- end
- end
- function coordina(xi)
- if coor.c == 5 or coor.c == 9 or coor.c == 1 then
- coor.c = 5
- end
- if xi then
- if coor.c == 6 or coor.c == 4 then
- coor.y = coor.y + 1
- end
- if coor.c == 8 or coor.c == 2 then
- coor.y = coor.y - 1
- end
- if coor.c == 5 or coor.c == 9 or coor.c == 1 then
- coor.x = coor.x + 1
- coor.c = 5
- end
- if coor.c == 7 or coor.c == 3 then
- coor.x = coor.x - 1
- end
- end
- end
- function turnLeft()
- if turtle.turnLeft() then
- coor.c = coor.c - 1
- end
- coordina()
- end
- function turnRight()
- if turtle.turnRight() then
- coor.c = coor.c + 1
- end
- coordina()
- end
- function swing()
- if i == 1 then
- turnLeft()
- fo()
- turnLeft()
- i = i + 1
- statis[3] = statis[3] + 1
- else
- if i == 2 then
- turnRight()
- fo()
- turnRight()
- i = i - 1
- statis[4] = statis[4] + 1
- else
- end
- end
- end
- function ref()
- while true do
- if turtle.getFuelLevel() > 0 then
- return true
- else
- shell.run('clear')
- monitor()
- print("Add Fuel")
- sleep(1)
- shell.run('refuel')
- end
- end
- end
- function fo()
- ref()
- if turtle.forward() then
- statis[2] = statis[2] + 1
- coordina(true)
- return true
- else
- return false
- end
- end
- function last()
- if statis[3] + statis[4] > coor.y then
- print( "End of the room: ", (statis[3] + statis[4])," > ", coor.y)
- return true
- end
- end
- function monitor()
- shell.run('clear')
- print()
- print("Fuel level is ", turtle.getFuelLevel())
- print("Blocks excavated ", statis[1])
- print("Distance travel ", statis[2])
- print("How many turns")
- print("left: ", statis[3], " right: ", statis[4])
- print("X: ", coor.x, " Y: ", coor.y, " Course: ", coor.c)
- print()
- end
- while true do
- if size ~= 0 then
- if size > statis[2] then
- else break
- end
- end
- if last() then
- break
- end
- if turtle.digDown() then
- statis[1] = statis[1] + 1
- end
- if not fo() then
- swing()
- end
- monitor()
- end
Advertisement
Add Comment
Please, Sign In to add comment