testfor----         The first command-block only command added in Minecraft Snapshot 13w03a. It tests for whether specified player is online (testfor [player]), or at specified coordinate and/or in radius (testfor @p[x,y,z], testfor @p[r=radius] or testfor @p[x,y,z,r=radius]) and signal output to any redstone comparators surrounding the command block like testing content of a chest.)
以上文字摘自 http://www.minecraftwiki.net/wiki/Commands

蓝色字
为可更改的值

testfor是第一条只能用在指令方块中的指令,在13w03a中被加入,它用来检测特定玩家是否存在(用法为/testfor [玩家]),或者特定玩家是否存在于特定坐标/范围内(用法为/testfor @p[x坐标,y坐标,z坐标],/testfor @p[r=一定范围]或者/testfor @p[x坐标,y坐标,z坐标,r=一定范围]),其输出的信号可以被周围的红石比较器接收,像是用红石比较器接收箱子的填满度一样

教程开始



这是未激活的情况



这是指令方块写的指令,意为以指令方块为中心,检测其半径为1的范围内是否存在玩家



当玩家不在检测范围内时,激活指令方块,比较器那也不会有输出



当玩家在检测范围内时再激活指令方块就有输出了



关掉拉杆,输出依然为1



离开检测范围,输出依然为1



离开检测范围并再次激活指令方块,输出为0



综上,如果想检测玩家暂时的位置,只需给指令方块一个 脉冲 信号,如果想一直检测玩家的位置就要给指令方块 时钟 信号