Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Home Coords
- xH = 1754
- yH = 5
- zH = -1040
- -- Coords when facing the center of the Wither
- xW = 1754
- yW = 5
- zW = -1030
- homeFace = 1 --direction to face when at home coords
- witherFace = 2 --direction to face when starts building the wither
- for k,v in pairs(rs.getSides()) do
- if peripheral.getType(v) == "modem" then
- rednet.open(v)
- end
- end
- function compass()
- print("Compass")
- compx,compy,compz = gps.locate()
- while turtle.forward() == false do
- turtle.turnRight()
- end
- x1,y1,z1 = gps.locate()
- direction = {compx = compx - x1, compy = compy - y1, compz = compz - z1}
- for k,v in pairs( direction ) do
- if k == "compx" and v == 1 then
- facing = 1 -- west
- print("Facing West")
- elseif k == "compx" and v == -1 then
- facing = 3 -- east
- print("Facing East")
- elseif k == "compz" and v == 1 then
- facing = 2 -- north
- print("Facing North")
- elseif k == "compz" and v == -1 then
- facing = 0 -- south
- print("Facing South")
- end
- end
- turtle.back()
- return facing
- end
- function goTo(xP,yP,zP)
- print("goto function")
- while true do
- xL,yL,zL = gps.locate()
- x = xL - xP
- y = yL - yP
- z = zL - zP
- print(x.." "..y.." "..z)
- if y > 0.5 then
- for i = 1,y do
- turtle.down()
- end
- elseif y < -0.5 then
- for i = y,0 do
- turtle.up()
- end
- elseif z < -0.5 then
- currentDir = compass()
- if currentDir ~= 0 then
- turnTo(0)
- end
- for i = z,0 do
- turtle.forward()
- end
- print("z less than 1")
- elseif z > 0.5 then
- currentDir = compass()
- if currentDir ~= 2 then
- turnTo(2)
- end
- for i = 1,z do
- turtle.forward()
- end
- elseif x < -0.5 then
- currentDir = compass()
- if currentDir ~= 3 then
- turnTo(3)
- end
- for i = x,0 do
- turtle.forward()
- end
- elseif x > 0.5 then
- currentDir = compass()
- if currentDir ~= 1 then
- turnTo(1)
- end
- for i = 1,x do
- turtle.forward()
- end
- else
- break
- end
- end
- end
- function buildWither()
- turtle.down()
- turtle.select(1)
- turtle.place()
- turtle.up()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- turtle.place()
- for i = 1, 2 do
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- turtle.place()
- end
- turtle.up()
- turtle.select(2)
- turtle.place()
- for i = 1,2 do
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- turtle.place()
- end
- turtle.down()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- end
- function turnTo(Int)
- if facing ~= Int then
- local current = facing - Int
- if current < 0 then
- for i = 1, math.abs(current) do
- turtle.turnRight()
- end
- else
- for i = 1,current do
- turtle.turnLeft()
- end
- end
- end
- end
- if fs.exists("abort") == false then
- print("Installing abort")
- shell.run("pastebin get eM0db9xZ abort")
- end
- shell.openTab("abort")
- sleep(1)
- goTo(xH,yH,zH)
- compass()
- turnTo(homeFace)
- print("home")
- while true do
- event, p1, p2, p3 = os.pullEvent("rednet_message")
- if tonumber(p3) == 33 and p2 == "BuildWither" then
- print("got message")
- goTo(xW,yW,zW)
- turnTo(witherFace)
- buildWither()
- goTo(xH,yH,zH)
- rednet.broadcast("WitherBuilt", 33)
- turtle.select(3)
- turtle.refuel(1)
- sleep(60)
- compass()
- turnTo(homeFace)
- else
- sleep(0.05)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement