Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- XPos = 0
- YPos = 0
- ZPos = 0
- InitialX = 0
- InitialY = 0
- InitialZ = 0
- Facing = 0 -- 0 - +x, 1 - -x, 2 - +z, 3 - -z
- function moveTo(x, y, z)
- end
- function correctPosition(expectedX, expectedY, expectedZ)
- end
- function getDimensions(data)
- local tab = {}
- for str in string.gmatch(data, "([^x]+)") do
- table.insert(tab, str)
- end
- return tab[1], tab[2], tab[3]
- end
- function turnAround()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- function setFacingDirection()
- if not turtle.detect() then
- turtle.forward()
- local x, y, z = gps.locate()
- if x > InitialX then
- Facing = 0
- elseif x < InitialX then
- Facing = 1
- elseif z > InitialZ then
- Facing = 2
- elseif z < InitialZ then
- Facing = 3
- end
- turnAround()
- turtle.forward()
- turnAround()
- end
- end
- function prepare()
- setFacingDirection()
- InitialY = InitialY - 1
- XPos, YPos, ZPos = InitialX, InitialY, InitialZ
- end
- function stripLayer(w, d)
- local pivotX, pivotY, pivotZ = InitialX, InitialY, InitialZ
- for i = 1, (d / 2) do
- while XPos < (pivotX + w - 1) do
- turtle.dig()
- turtle.forward()
- XPos, YPos, ZPos = gps.locate()
- end
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- XPos, YPos, ZPos = gps.locate()
- pivotX, pivotY, pivotZ = XPos, YPos, ZPos
- while XPos > (pivotX - w + 1) do
- turtle.dig()
- turtle.forward()
- XPos, YPos, ZPos = gps.locate()
- end
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- XPos, YPos, ZPos = gps.locate()
- pivotX, pivotY, pivotZ = XPos, YPos, ZPos
- end
- end
- function move(w, d, h)
- for i = 1, h do
- turtle.digDown()
- turtle.down()
- stripLayer(w, d)
- turtle.turnRight()
- for j = 1, w do
- turtle.forward()
- end
- turtle.turnLeft()
- end
- end
- function main()
- local modem = peripheral.find("modem", rednet.open)
- rednet.broadcast("turtle", "turtnettoserver")
- local id, message = rednet.receive("turtnettoclient")
- local width, height, depth = getDimensions(message)
- InitialX, InitialY, InitialZ = gps.locate()
- turtle.refuel()
- prepare()
- move(width, depth, height)
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement