Difference between revisions of "Command Block (API)"
From ComputerCraft Wiki
Negamartin (Talk | contribs) |
|||
Line 2: | Line 2: | ||
(The peripheral can only be used if allowed in the config, which is default to false) | (The peripheral can only be used if allowed in the config, which is default to false) | ||
− | Functions exposed by the Command Block: | + | Functions exposed by the Command Block, where commandBlock is warped to a command block : |
{| border="1" cellpadding="2" cellspacing="0" | {| border="1" cellpadding="2" cellspacing="0" | ||
!style="background:#EEE" width="200px"|Function | !style="background:#EEE" width="200px"|Function | ||
!style="background:#EEE" width="*"|Description | !style="background:#EEE" width="*"|Description | ||
|- | |- | ||
− | |getCommand( ) | + | |[[commandBlock.getCommand]]( ) |
|Returns a string containing the command currently inside the Command Block. | |Returns a string containing the command currently inside the Command Block. | ||
|- | |- | ||
− | |setCommand( [[string_(type)|string]] command ) | + | |[[commandBlock.setCommand]]( [[string_(type)|string]] command ) |
|Sets the command in the Command Block. '''This does not run it.''' | |Sets the command in the Command Block. '''This does not run it.''' | ||
|- | |- | ||
− | |runCommand( ) | + | |[[commandBlock.runCommand]]( ) |
− | |Runs the command inside the Command Block previously set by setCommand( ) | + | |Runs the command inside the Command Block previously set by [[commandBlock.setCommand]]( ) |
|} | |} | ||
Line 21: | Line 21: | ||
'''example''': | '''example''': | ||
<span> | <span> | ||
− | + | commandBlock = [[peripheral.wrap]]("left") | |
− | + | commandBlock.setCommand("time set 1000") | |
− | + | commandBlock.runCommand() | |
− | local currentCommand = | + | local currentCommand = commandBlock.getCommand() |
</span> | </span> | ||
[[Category:Peripheral APIs]] | [[Category:Peripheral APIs]] |
Revision as of 21:09, 30 March 2013
The Command Block API allows you to run commands in a Command Block, using it as a peripheral. (The peripheral can only be used if allowed in the config, which is default to false)
Functions exposed by the Command Block, where commandBlock is warped to a command block :
Function | Description |
---|---|
commandBlock.getCommand( ) | Returns a string containing the command currently inside the Command Block. |
commandBlock.setCommand( string command ) | Sets the command in the Command Block. This does not run it. |
commandBlock.runCommand( ) | Runs the command inside the Command Block previously set by commandBlock.setCommand( ) |
Note
All Command Block functions are to be used after wrapping the block in a peripheral. example:
commandBlock = peripheral.wrap("left") commandBlock.setCommand("time set 1000") commandBlock.runCommand() local currentCommand = commandBlock.getCommand()