Jump to content




Computercraft and player detection


4 replies to this topic

#1 KrisRevi

  • Members
  • 14 posts

Posted 25 June 2016 - 09: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!

#2 The Higher Realm

  • Members
  • 23 posts
  • LocationUSA

Posted 26 June 2016 - 03: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 by Actiquack322, 26 June 2016 - 03:11 AM.


#3 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 26 June 2016 - 05: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.

#4 KrisRevi

  • Members
  • 14 posts

Posted 26 June 2016 - 12:06 PM

View PostActiquack322, on 26 June 2016 - 03:09 AM, said:

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?

#5 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 26 June 2016 - 01: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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users