• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

bit_Shifted Mar 20th, 2019 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. local scanner = peripheral.wrap("right")
2. local p_mc = "minecraft:"
3. local scanned = scanner.scan()
4. local turnsToSouth = {"south" = 0, "north" = 2 "west" = 3, "east" = 1}--right turns
5.
6. function moveTo(x, y, z)
7.     local currentPos = vector.new(gps.locate())
8.     local blocksToMoveX = x - currentPos.x
9.     local blocksToMoveY = y - currentPos.y
10.     local blocksToMoveZ = z - currentPos.z
11.     local dir = scanner.getBlockMeta(0,0,0).state.facing
12.     for i = 0,turnsToSouth[dir] do
13.         turtle.turnRight()
14.     end
15.     if blocksToMoveY > 0 then
16.         for i = 1,math.abs(blocksToMoveY) do
17.             turtle.up()
18.         end
19.     elseif blocksToMoveY < 0 then
20.         for i = 1,math.abs(blocksToMoveY) do
21.             turtle.down()
22.         end
23.     end
24.
25.     turtle.turnLeft()
26.     if blocksToMoveX > 0 then
27.         for i = 1,math.abs(blocksToMoveX) do
28.             turtle.forward()
29.         end
30.     elseif blocksToMoveX < 0 then
31.         for i = 1,math.abs(blocksToMoveX) do
32.             turtle.back()
33.         end
34.     end
35.
36.     turtle.turnRight()
37.
38.     if blocksToMoveZ > 0 then
39.         for i = 1,math.abs(blocksToMoveZ) do
40.             turtle.forward()
41.         end
42.     elseif blocksToMoveZ < 0 then
43.         for i = 1,math.abs(blocksToMoveZ) do
44.             turtle.back()
45.         end
46.     end
47. end
48.
49. local currentPos = vector.new(gps.locate())
50. moveTo(-148, 56, -356)
51.
52. for _, b in pairs(scanned) do
53.     if b.name == p_mc.."log" then
54.         print(b.name.." found at: "..b.x.." "..b.y.." "..b.z)
55.     end
56. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top