Command Block (API)

From ComputerCraft Wiki
Revision as of 21:16, 30 March 2013 by Lyqyd (Talk | contribs) (Fix typo (Where does peripheral "warping" come from, anyhow?))

Jump to: navigation, search

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:

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()