Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[VARIABLES]]--
- local mineHeight = 0;
- local run = true;
- local currentRotation = 0
- local currentYPosition = 0
- local currentZPosition = 0
- local oldYPosition = 0
- local oldZPosition = 0
- local oldRotation = 0
- --[[BASIC FUNCTIONS]]--
- function updateScreen()
- term.clear()
- term.setCursorPos(1, 1)
- print("LOGAN'S MINING SYSTEM")
- print("Y: " .. currentYPosition)
- print("Z: " .. currentZPosition)
- print("ROTATION: " .. currentRotation)
- print("FUEL: " .. turtle.getFuelLevel() .. " / " .. turtle.getFuelLimit())
- print("OLD Y POSTIION: " .. oldYPosition)
- print("OLD Z POSITION: " .. oldZPosition)
- end
- function turnLeft()
- currentRotation = currentRotation - 1;
- turtle.turnLeft()
- end
- function turnRight()
- currentRotation = currentRotation + 1;
- turtle.turnRight()
- end
- function dig()
- updateScreen()
- if turtle.getItemCount(16) == 0 then
- turtle.dig()
- else
- returnToHome()
- deposit()
- returnToOldPosition()
- turtle.dig()
- end
- end
- function digUp()
- updateScreen()
- if turtle.getItemCount(16) == 0 then
- turtle.digUp()
- else
- returnToHome()
- deposit()
- returnToOldPosition()
- end
- end
- function digDown()
- updateScreen()
- if turtle.getItemCount(16) == 0 then
- turtle.digDown()
- else
- returnToHome()
- deposit()
- returnToOldPosition()
- end
- end
- function deposit()
- for i = 1, 16 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.select(1)
- end
- function forward()
- updateScreen()
- turtle.forward()
- if currentRotation == 0 then
- currentZPosition = currentZPosition + 1
- elseif currentRotation == 1 then
- currentXPosition = currentXPosition + 1
- elseif currentRotation == -1 then
- currentXPosition = currentXPosition - 1
- else
- currentZPosition = currentZPosition - 1
- end
- end
- --[[MOVEMENT ACTIONS]]--
- function oddLevelDig()
- dig()
- turnRight()
- dig()
- turnRight()
- dig()
- end
- function evenLevelDig()
- dig()
- turnLeft()
- dig()
- turnLeft()
- dig()
- end
- function turnStraight()
- if currentRotation > 0 then
- repeat
- turnLeft()
- until currentRotation == 0
- else
- repeat
- turnRight()
- until currentRotation == 0
- end
- end
- function turnBackwards()
- if currentRotation > 0 then
- repeat
- turnRight()
- until currentRotation == 2
- else
- repeat
- turnLeft()
- until currentRotation == -2
- end
- end
- function returnToHome()
- oldRotation = currentRotation
- oldYPosition = currentYPosition
- oldZPosition = currentZPosition
- turnBackwards()
- repeat
- forward()
- until currentZPosition == 0
- for i = 1, currentYPosition do
- turtle.down()
- end
- end
- function returnToOldPosition()
- turnStraight()
- repeat
- forward()
- until currentZPosition == oldZPosition
- for i = 1, currentYPosition do
- turtle.up()
- end
- if oldRotation == -1 then
- turnLeft()
- else
- turnRight()
- end
- end
- write("Mine Height: ")
- mineHeight = tonumber(read());
- turtle.select(1)
- turtle.refuel()
- while run do
- turnLeft()
- for i = 1, mineHeight do
- if i % 2 == 1 then
- oddLevelDig()
- else
- evenLevelDig()
- end
- if i ~= mineHeight then
- digUp()
- turtle.up()
- currentYPosition = currentYPosition + 1
- end
- end
- turnStraight()
- forward()
- turnLeft()
- for i = mineHeight, 1, -1 do
- if i % 2 == 1 then
- oddLevelDig()
- else
- evenLevelDig()
- end
- if i ~= 1 then
- digDown()
- turtle.down()
- currentYPosition = currentYPosition - 1
- end
- end
- turnStraight()
- forward()
- end
- --loadstring(http.get("https://pastebin.com/raw/EpEm4WZ3").readAll())()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement