Commandblock API

From ComputerCraft
⧼vector-jumptonavigation⧽ ⧼vector-jumptosearch⧽
FunctionFunctioncommandblock.getCommand
Returns the command from a commandblock. Note Note: The commandblock peripheral is disabled by default. You have to enable it in the config before using it.
Syntax commandblock.getCommand()
Returns string command
Part of CC:Tweaked (source)
API commandblock
ExampleExampleGet command
Get Command and print it.
Code
local commandblockr = peripheral.find("command")
print(commandblock.getCommand())
Output
kill @a


FunctionFunctioncommandblock.runCommand
Run a command from a commandblock. Note Note: The commandblock peripheral is disabled by default. You have to enable it in the config before using it.
Syntax commandblock.runCommand()
Returns boolean success string error
Part of CC:Tweaked (source)
API commandblock
ExampleExampleRun command
Run command.
Code
local commandblock = peripheral.find("command")
print(commandblock.runCommand())
Output
true


FunctionFunctioncommandblock.setCommand
Set the command of a commandblock. Note Note: The commandblock peripheral is disabled by default. You have to enable it in the config before using it.
Syntax commandblock.setCommand()
Returns nil
Part of CC:Tweaked (source)
API commandblock
ExampleExampleSet command
Set command.
Code
local commandblock = peripheral.find("command")
commandblock.setCommand("kill @a")