This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
KrisRevi's profile picture

Computercraft and player detection

Started by KrisRevi, 25 June 2016 - 08:32 PM
KrisRevi #1
Posted 25 June 2016 - 10:32 PM
Hi there.

im currently googling my ass of about computercraft and player detection now this is fairly easy but my question is, is it only "player detector" from "MiscPeripherals" mod that has the function to get the player NAME? I've seen a tutorial where they use it and they can os.pullEvent("player") and then print the name of the player on computecraft monitor!!

i love the draconic evolution "advanced player detection" block cause you dont have to right click it to make it detect player! but i cant find any info on that block if it can detect player NAME!
The Higher Realm #2
Posted 26 June 2016 - 04:09 AM
Without any extra mods you can use a command computer and use

while true do
    if command.exec("/testfor @p [r=5,name=KrisRevi]") then
        print("Found KrisRevi")
    end
end
but I can't think of any way of getting it without MiscPeripherals or a command computer.
Edited on 26 June 2016 - 02:11 AM
Bomb Bloke #3
Posted 26 June 2016 - 06:24 AM
os.pullEvent() doesn't generate event data, it collects it - if no one clicks the detector block then the script sits on that line until someone does.

Usually the sensors from OpenCCSensors or OpenPeripheral are used to find players within a given area.
KrisRevi #4
Posted 26 June 2016 - 01:06 PM
Without any extra mods you can use a command computer and use

while true do
	if command.exec("/testfor @p [r=5,name=KrisRevi]") then
		print("Found KrisRevi")
	end
end
but I can't think of any way of getting it without MiscPeripherals or a command computer.

does this scan the entire area/server? or?
Bomb Bloke #5
Posted 26 June 2016 - 02:26 PM
That particular command checks to see if the closest player, within a radius of five blocks around where the command was executed, has the name of "KrisRevi".

If you want to use a Command Computer for this, you may find this useful. If you want to build the commands yourself, you can read up on the syntax here.