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

Command block input?

Started by jag, 03 February 2013 - 04:10 AM
jag #1
Posted 03 February 2013 - 05:10 AM
So I know that you can set the command and launch it on a command block via a computer.
You can even get the current command from the command block (doe with my experience that usually gives a error, bug?)

local c = peripheral.wrap( side )
c.setCommand( command )
c.runCommand()
c.getCommand()

But (this is the part I wanted to come to) is there a way to get any kind of input from the command block?
The way I am going to put it now it is going to sound like it belongs to the "Suggestions" category.

It would be cool, and maybe awesome if you get like a event or something similar from the command block.

Ex 1:
This stands in the command block:
+-------------------+
| /ComputerCraft @a |
+-------------------+

local ev,p1,p2,p3 = os.pullEvent()

ev
[string]> command_block

p1
[string, side]> left

p2
[string, task]> players_all

p3
[table of users]> players

Ex 2:
This stands in the command block:
+------------------------------------------+
| /ComputerCraft @p[x=138,y=119,z=57,r=20] |
+------------------------------------------+

local ev,p1,p2,p3 = os.pullEvent()

ev
[string]> command_block

p1
[string, side]> left

p2
[string, task]> player_nearest

p3
[string, player]> jag_e_nummer_ett

This is just a though doe, but is there another way of getting that kind of player information (aka list of online players)?
And I do not want you to think about Misc.Peripherals and its player detector, because it requires a rightclick.
Lyqyd #2
Posted 16 July 2013 - 01:41 PM
This wouldn't be possible without modifying the way command blocks work, but if you're not too attached to using command blocks to do it, you can find information on players and other entities using OpenCCSensors.