Difference between revisions of "Command Block (API)"
From ComputerCraft Wiki
m (Fix typo (Where does peripheral "warping" come from, anyhow?)) |
Smiley43210 (Talk | contribs) (Updated table to v2) |
||
Line 3: | Line 3: | ||
Functions exposed by the Command Block, where commandBlock is wrapped to a command block: | Functions exposed by the Command Block, where commandBlock is wrapped to a command block: | ||
− | + | ||
− | + | <table style="width: 100%; border: solid 1px black; margin: 2px; border-spacing: 0px;"> | |
− | + | <tr><td colspan="2" style="font-weight: bold; font-size: large; padding-bottom: .3em; border-bottom: solid #C9C9C9 1px; background: #D3FFC2; line-height:28px;"> | |
− | + | [[File:Grid_disk.png|24px]] | |
− | + | Command Block (API) | |
− | + | </td></tr> | |
− | + | ||
− | + | <tr><td style="width: 350px; background: #E0E0E0; padding: .4em; font-weight:bold;">Method Name</td><td style="background: #E0E0E0; padding: .4em; font-weight:bold;">Description</td></tr> | |
− | + | ||
− | + | <tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[commandBlock.getCommand]]()</td> | |
− | + | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns a string containing the command currently inside the Command Block.</td></tr> | |
− | + | ||
− | + | <tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[commandBlock.setCommand]]({{type|string}} command)</td> | |
+ | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Sets the command in the Command Block to ''command''. '''This does not run it.'''</td></tr> | ||
+ | |||
+ | <tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[commandBlock.runCommand]]()</td> | ||
+ | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Runs the command inside the Command Block previously set by manually editing it or by using [[commandBlock.setCommand]]()</td></tr> | ||
+ | </table> | ||
==Note== | ==Note== |
Revision as of 13:51, 15 May 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 wrapped to a command block:
Method Name | 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 to command. This does not run it. |
commandBlock.runCommand() | Runs the command inside the Command Block previously set by manually editing it or by using 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()