Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local scanner = peripheral.wrap("right")
- local p_mc = "minecraft:"
- local scanned = scanner.scan()
- local turnsToSouth = {["south"] = 0, ["north"] = 2, ["west"] = 3, ["east"] = 1}--right turns
- function moveTo(x, y, z)
- local currentPos = vector.new(gps.locate())
- local blocksToMoveX = x - currentPos.x
- local blocksToMoveY = y - currentPos.y
- local blocksToMoveZ = z - currentPos.z
- local dir = scanner.getBlockMeta(0,0,0).state.facing
- for i = 0,turnsToSouth[dir] do
- turtle.turnRight()
- end
- if blocksToMoveY > 0 then
- for i = 1,math.abs(blocksToMoveY) do
- turtle.up()
- end
- elseif blocksToMoveY < 0 then
- for i = 1,math.abs(blocksToMoveY) do
- turtle.down()
- end
- end
- turtle.turnLeft()
- if blocksToMoveX > 0 then
- for i = 1,math.abs(blocksToMoveX) do
- turtle.forward()
- end
- elseif blocksToMoveX < 0 then
- for i = 1,math.abs(blocksToMoveX) do
- turtle.back()
- end
- end
- turtle.turnRight()
- if blocksToMoveZ > 0 then
- for i = 1,math.abs(blocksToMoveZ) do
- turtle.forward()
- end
- elseif blocksToMoveZ < 0 then
- for i = 1,math.abs(blocksToMoveZ) do
- turtle.back()
- end
- end
- end
- local currentPos = vector.new(gps.locate())
- moveTo(-148, 56, -356)
- for _, b in pairs(scanned) do
- if b.name == p_mc.."log" then
- print(b.name.." found at: "..b.x.." "..b.y.." "..b.z)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement