Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --file:movement
- --pastebin:CGxL2Ymr
- -- Movement api.
- moveSleep = 0.2
- paintSleep = 0.5
- blockedMoveSleep = 2
- reservedSlots = 0
- function turtleForward()
- local moveSuccess = false
- while (not moveSuccess) do
- while turtle.detect() do
- turtle.dig()
- sleep(moveSleep)
- end
- moveSuccess = turtle.forward()
- if (not moveSuccess) then
- sleep(blockedMoveSleep)
- end
- end
- end
- function turtleForwardX(count)
- for i = 1, count do
- turtleForward()
- end
- end
- function turtleUp()
- local moveSuccess = false
- while (not moveSuccess) do
- while turtle.detectUp() do
- turtle.digUp()
- sleep(moveSleep)
- end
- moveSuccess = turtle.up()
- if (not moveSuccess) then
- sleep(blockedMoveSleep)
- end
- end
- end
- function turtleUpX(count)
- for i = 1, count do
- turtleUp()
- end
- end
- function turtleDown()
- local moveSuccess = false
- while (not moveSuccess) do
- while turtle.detectDown() do
- turtle.digDown()
- sleep(moveSleep)
- end
- moveSuccess = turtle.down()
- if (not moveSuccess) then
- sleep(blockedMoveSleep)
- end
- end
- end
- function turtleDownX(count)
- for i = 1, count do
- turtleDown()
- end
- end
- function selectMaterial(typeSlot)
- turtle.select(typeSlot)
- if turtle.getItemCount(typeSlot) > 1 then
- return true
- else
- for otherSlot = 16, 1, -1 do
- if (turtle.compareTo(otherSlot)) then
- if otherSlot <= reservedSlots then
- if turtle.getItemCount(otherSlot) > 1 then
- turtle.select(otherSlot)
- return true
- end
- else
- turtle.select(otherSlot)
- return true
- end
- end
- end
- end
- return false
- end
- function paintForward(typeSlot)
- if selectMaterial(typeSlot) then
- if not turtle.compare() then
- while turtle.detect() do
- turtle.dig()
- sleep(paintSleep)
- end
- turtle.place()
- end
- end
- end
- function paintDown(typeSlot)
- if selectMaterial(typeSlot) then
- if not turtle.compareDown() then
- turtle.digDown()
- turtle.placeDown()
- end
- end
- end
- function paintUp(typeSlot)
- if selectMaterial(typeSlot) then
- if not turtle.compareUp() then
- while turtle.detectUp() do
- turtle.digUp()
- sleep(paintSleep)
- end
- turtle.placeUp()
- end
- end
- end
- function turn(turnRight)
- if turnRight then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement