Difference between revisions of "Command Block (API)"
From ComputerCraft Wiki
Negamartin (Talk | contribs) (Created the page) |
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: | |
− | + | {| border="1" cellpadding="2" cellspacing="0" | |
− | + | !style="background:#EEE" width="200px"|Function | |
− | + | !style="background:#EEE" width="*"|Description | |
− | + | |- | |
− | + | |getCommand( ) | |
− | + | |Returns a string containing the command currently inside the Command Block. | |
− | + | |- | |
− | + | |setCommand( [[string_(type)|string]] command ) | |
− | + | |Sets the command in the Command Block. '''This does not run it.''' | |
− | + | |- | |
− | + | |runCommand( ) | |
− | + | |Runs the command inside the Command Block previously set by setCommand( ) | |
− | + | |} | |
==Note== | ==Note== | ||
All Command Block functions are to be used ''after'' wrapping the block in a peripheral. | All Command Block functions are to be used ''after'' wrapping the block in a peripheral. | ||
− | '''example''': command = peripheral.wrap("left") | + | '''example''': |
+ | <span> | ||
+ | command = peripheral.wrap("left") | ||
+ | command.setCommand("time set 1000") | ||
+ | command.runCommand() | ||
+ | local currentCommand = command.getCommand() | ||
+ | </span> | ||
[[Category:Peripheral APIs]] | [[Category:Peripheral APIs]] |
Revision as of 06:10, 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:
Function | Description |
---|---|
getCommand( ) | Returns a string containing the command currently inside the Command Block. |
setCommand( string command ) | Sets the command in the Command Block. This does not run it. |
runCommand( ) | Runs the command inside the Command Block previously set by setCommand( ) |
Note
All Command Block functions are to be used after wrapping the block in a peripheral. example:
command = peripheral.wrap("left") command.setCommand("time set 1000") command.runCommand() local currentCommand = command.getCommand()