Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sensor = peripheral.wrap("left")
- modemw = peripheral.wrap("right")
- local function moveto(dirant,diratu)
- if dirant == "norte" then
- if diratu == "leste" then
- turtle.turnRight()
- elseif diratu == "oeste" then
- turtle.turnLeft()
- elseif diratu == "sul" then
- turtle.turnRight()
- turtle.turnRight()
- end
- elseif dirant == "leste" then
- if diratu == "sul" then
- turtle.turnRight()
- elseif diratu == "norte" then
- turtle.turnLeft()
- elseif diratu == "oeste" then
- turtle.turnRight()
- turtle.turnRight()
- end
- elseif dirant == "sul" then
- if diratu == "oeste" then
- turtle.turnRight()
- elseif diratu == "leste" then
- turtle.turnLeft()
- elseif diratu == "norte" then
- turtle.turnRight()
- turtle.turnRight()
- end
- elseif dirant == "oeste" then
- if diratu == "norte" then
- turtle.turnRight()
- elseif diratu == "sul" then
- turtle.turnLeft()
- elseif diratu == "leste" then
- turtle.turnRight()
- turtle.turnRight()
- end
- end
- if turtle.detect() == true then
- turtle.equipRight()
- turtle.dig()
- turtle.equipRight()
- end
- turtle.forward()
- end
- direcao = "norte"
- term.clear()
- term.setCursorPos(1,1)
- print("Insert Your Nickname / Insira Seu Nome de Jogador")
- nickname = io.read()
- term.clear()
- term.setCursorPos(1,1)
- print("Insert the Turtle Height / Insira a Altura da Turtle")
- altura = tonumber(io.read())
- term.clear()
- term.setCursorPos(1,1)
- print("Following"..nickname.." / Seguindo "..nickname)
- while 1 == 1 do
- posicao = "naoconferida"
- yourinfo = sensor.getPlayerData(nickname)
- xpronto = math.floor((tonumber(yourinfo["position"]["x"]))+0.5)
- zpronto = math.floor((tonumber(yourinfo["position"]["z"]))+0.5)
- ypronto = math.floor(((tonumber(yourinfo["position"]["y"]))+0.5)+altura)
- if ypronto > 0 then
- if turtle.detectUp() == true then
- turtle.equipRight()
- turtle.digUp()
- turtle.equipRight()
- end
- turtle.up()
- elseif ypronto < 0 then
- if turtle.detectDown() == true then
- turtle.equipRight()
- turtle.digDown()
- turtle.equipRight()
- end
- turtle.down()
- elseif ypronto == 0 then
- if zpronto > 0 then
- moveto(direcao,"sul")
- direcao = "sul"
- elseif zpronto < 0 then
- moveto(direcao,"norte")
- direcao = "norte"
- elseif zpronto == 0 then
- if xpronto > 0 then
- moveto(direcao,"leste")
- direcao = "leste"
- elseif xpronto < 0 then
- moveto(direcao,"oeste")
- direcao = "oeste"
- elseif xpronto == 0 then
- posicao = "conferida"
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement