Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- DEFAULTS TO TURNING TURTLE NORTH ( Z - AXIS )
- function faceNorth()
- local startX, startY, startZ = gps.locate()
- startY = nil
- turtle.back()
- local endX, endY, endZ = gps.locate()
- endY = nil
- turtle.forward()
- if(endX < startX) then turtle.turnLeft()
- elseif (endX > startX) then turtle.turnRight()
- elseif (endZ < startZ) then turtle.turnRight() turtle.turnRight()
- end
- end
- -- MOVES TO COORDINATES X, Y, Z
- function moveTo(x, y, z)
- faceNorth()
- local curX, curY, curZ = gps.locate()
- local xDist = math.abs(x - curX)
- local yDist = math.abs(y - curY)
- local zDist = math.abs(z - curZ)
- local xMethod local yMethod local zMethod
- if (curX > x) then xMethod = turtle.back else xMethod = turtle.forward end
- if (curY > y) then yMethod = turtle.down else yMethod = turtle.up end
- if (curZ > z) then zMethod = turtle.back else zMethod = turtle.forward end
- while (zDist > 0) do
- zMethod()
- zDist = zDist - 1
- end
- turtle.turnLeft()
- while (xDist > 0) do
- xMethod()
- xDist = xDist - 1
- end
- while (yDist > 0) do
- yMethod()
- yDist = yDist - 1
- end
- end
- function resetPos()
- local file = fs.open("Settings", "r")
- local startX = file.readLine()
- local startY = file.readLine()
- local startZ = file.readLine()
- file.close()
- moveTo(startX, startY, startZ)
- end
- function getSeedIndex()
- for slot = 1, 16, 1 do
- local item = turtle.getItemDetail(slot)
- if ( (item ~= nil) and ( (string.match(item.name, "seed") ) or (string.match(item.name, "potato") ) or (string.match(item.name, "carrot") ) ) ) then
- return slot
- end
- end
- end
- function getCrop()
- local isBlock, data = turtle.inspectDown()
- if(isBlock)then
- if ( ( string.match(data.name, "croptopia:") or string.match(data.name, "wheat") or string.match(data.name, "potato") or string.match(data.name, "carrot")) and data['state']['age'] == 7) then
- turtle.digDown()
- seedIndex = getSeedIndex()
- if(seedIndex ~= nil) then
- turtle.select(seedIndex)
- turtle.placeDown()
- end
- end
- else
- seedIndex = getSeedIndex()
- if(seedIndex ~= nil) then
- turtle.digDown()
- turtle.select(seedIndex)
- turtle.placeDown()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement