Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Turtle Adventurer V2
- -- By CaptainSpaceCat
- -- This program will send a turtle off into the wilderness to travel in a straight line as far as possible
- -- You must equip the turtle with 3 chunk loaders so that it can load the chunk it's in and the next one
- -- You should also give it an rftools Matter Receiver so that you can teleport to it once it gets thousands of blocks away!
- -- NOTE: you MUST start the turtle ONE BLOCK AWAY from the edge of a chunk, facing INTO the chunk
- -- otherwise the chunk loaders won't work properly
- -- CHANGES
- -- Turtle will now log all landmasses it travels over
- -- it does this by keeping track of its coordinates and logging chunks where it has to break terrain at least once
- -- you should place it one block above sea level for this to work as well as possible
- -- you MUST enter its initial coordinates and rotation accurately for this to be useful
- shell.run("delete travel_log")
- local anchorSlot = 1
- local receiverSlot = 2
- local tArgs = {...}
- local terrainFlag = false
- local coords = {}
- local chunks = turtle.getFuelLevel() / 48
- local function getCoords()
- print("Turtle's X coordinate: ")
- coords.x = tonumber(read())
- print("Turtle's Y coordinate: ")
- coords.y = tonumber(read())
- print("Turtle's Z coordinate: ")
- coords.z = tonumber(read())
- print("Turtle's direction: ")
- print("1 - north")
- print("2 - east")
- print("3 - west")
- print("4 - south")
- coords.f = tonumber(read())
- print("Desired number of chunks to travel:")
- print("(Leave empty to go as far as fuel allows)")
- local c = tonumber(read())
- if not c == nil then
- chunks = c
- end
- end
- local function log(message)
- handle = fs.open("travel_log", "a")
- handle.writeLine(message)
- handle.close()
- end
- local dirTab = {
- {0, -1}, --north
- {1, 0}, --south
- {0, 1}, --east
- {-1, 0} --west
- }
- local function forward(num)
- num = num or 1
- for i = 1, num do
- if turtle.detect() then
- turtle.dig()
- terrianFlag = true
- end
- turtle.forward()
- coords.x = coords.x + dirTab[coords.f][1]
- coords.z = coords.z + dirTab[coords.f][2]
- end
- end
- local function up(num)
- num = num or 1
- for i = 1, num do
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.up()
- coords.y = coords.y + 1
- end
- end
- local function down(num)
- num = num or 1
- for i = 1, num do
- if turtle.detectDown() then
- turtle.digDown()
- end
- turtle.down()
- coords.y = coords.y - 1
- end
- end
- local function left(num)
- num = num or 1
- for i = 1, num do
- turtle.turnLeft()
- coords.f = ((coords.f + 2) % 4) + 1
- end
- end
- local function right(num)
- num = num or 1
- for i = 1, num do
- turtle.turnRight()
- coords.f = (coords.f % 4) + 1
- end
- end
- local function placeAnchor()
- turtle.dig()
- turtle.select(anchorSlot)
- turtle.place()
- end
- local function placeAnchorUp()
- turtle.digUp()
- turtle.select(anchorSlot)
- turtle.placeUp()
- end
- local function pickupAnchor()
- turtle.select(anchorSlot)
- turtle.dig()
- end
- local function loop(chunks)
- for i = 1, chunks do
- terrainFlag = false
- forward(14)
- placeAnchor()
- placeAnchorUp()
- left(2)
- forward(14)
- pickupAnchor()
- left(2)
- forward(14)
- right()
- forward()
- left()
- forward()
- up()
- left()
- forward()
- left()
- pickupAnchor()
- left(2)
- forward()
- down()
- if terrainFlag then
- log(tostring(coords.x) .. "|" .. tostring(coords.z))
- end
- end
- end
- local function placeReceiver()
- turtle.select(receiverSlot)
- turtle.dig()
- turtle.place()
- end
- getCoords()
- print("Adventuring approximately " .. tostring(chunks) .. " chunks!")
- loop(chunks)
- placeReceiver()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement