How to use radar to detect other players

Started by MegaMind, Oct 19, 2021, 09:10 PM

Previous topic - Next topic

MegaMind

I'm very new to this and I wanted to use a radar to detect other players and give me their distance from the radar. But I don't even know how to get the computer to interact with the radar. I tried looking for videos that could show how to do it but couldn't find any. I was told I should ask for help here, so can someone tell how do something like this or show me video that can do the same?

Lupus590

What mod is the radar from? CC doesn't have any native ability to detect entities so some peripheral mod must be providing it, there are a few which do so knowing which specific one you are using will be helpful.

MegaMind

Quote from: Lupus590 on Oct 19, 2021, 11:44 PMWhat mod is the radar from? CC doesn't have any native ability to detect entities so some peripheral mod must be providing it, there are a few which do so knowing which specific one you are using will be helpful.
the radar is from "computronics" I saw it combined with a turtle so I assumed it was from the same mod, now I know that they work together but I still don't know what to do to make it talk with the computer.

Lupus590

I would assume that it has a block form as well as a turtle upgrade form, but I'm not familiar with the mod so I can't say for sure.

MrSevyu

#4
The peripheral must be on any of the sides of your computer (left, right, front, back, top, bottom). Go to Peripheral Basics for more information.
I wrote this sample code. It gets all nearby players and their distance to the radar.

local radar = peripheral.wrap("left")
local players = radar.getPlayers()

local playerName = ""
local distance = 0

for i = 1, #players do
    for k, v in pairs(players) do
        if players[i]["name"] ~= "" or players[i]["name"] ~= nil then
            playerName = players[i]["name"]
        end
        if players[i]["distance"] ~= nil then
            distance = players[i]["distance"]
        end
        print("Player: " .. playerName .. " -- Distance: " .. distance)
    end
end