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
- local function glassradar()
- pnames = sensor.getPlayerNames()
- mobids = sensor.getMobIds()
- numnames = #pnames
- numids = #mobids
- tabinfo={}
- for n=1,numnames do
- pinfo = sensor.getPlayerData(pnames[n])
- a=((n*3)-2)
- b=((n*3)-1)
- c=(n*3)
- infoposi = pinfo["position"]
- posx = tonumber(infoposi["x"])
- posy = tonumber(infoposi["z"])
- aposx = math.floor(posx+0.5)
- aposy = math.floor(posy+0.5)
- xdotcc = (aposx + 24)
- ydotcc = (aposy + 24)
- if xdotcc > 47 then xfinal = "47"
- elseif xdotcc < 1 then xfinal = "1"
- else xfinal = tostring(xdotcc)
- end
- if ydotcc > 47 then yfinal = "47"
- elseif ydotcc < 1 then yfinal= "1"
- else yfinal = tostring(ydotcc)
- end
- if pnames[n] == "TorakWolf" then
- cor = "w"
- else
- cor = "r"
- end
- tabinfo[a] = cor
- tabinfo[b] = xfinal
- tabinfo[c] = yfinal
- end
- for h=1,numids do
- mobinfo = sensor.getMobData(mobids[h])
- d=(((h*3)-2)+numnames*3)
- e=(((h*3)-1)+numnames*3)
- f=((h*3)+(numnames*3))
- infoposi = mobinfo["position"]
- posx = tonumber(infoposi["x"])
- posy = tonumber(infoposi["z"])
- aposx = math.floor(posx+0.5)
- aposy = math.floor(posy+0.5)
- xdotcc = (aposx + 24)
- ydotcc = (aposy + 24)
- if xdotcc > 47 then xfinal = "47"
- elseif xdotcc < 1 then xfinal = "1"
- else xfinal = tostring(xdotcc)
- end
- if ydotcc > 47 then yfinal = "47"
- elseif ydotcc < 1 then yfinal= "1"
- else yfinal = tostring(ydotcc)
- end
- if mobinfo["type"] == "Zombie" or mobinfo["type"] == "Skeleton" or mobinfo["type"] == "Spider"then
- cor = "o"
- else
- cor = "g"
- end
- tabinfo[d] = cor
- tabinfo[e] = xfinal
- tabinfo[f] = yfinal
- end
- msgfinalser = textutils.serialize(tabinfo)
- modemw.transmit(1310,1,msgfinalser)
- sleep(0.3)
- 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
- if posicao == "conferida" then
- glassradar()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement