Commandblock API

Functioncommandblock.getCommand
Returns the command from a commandblock.  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
ExampleGet command
Get Command and print it.
Code
<nowiki>
local commandblockr = peripheral.find("command")
print(commandblock.getCommand())
    </nowiki>
Output
kill @a
Functioncommandblock.runCommand
Run a command from a commandblock.  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
ExampleRun command
Run command.
Code
<nowiki>
local commandblock = peripheral.find("command")
print(commandblock.runCommand())
    </nowiki>
Output
true
Functioncommandblock.setCommand
Set the command of a commandblock.  Note: The commandblock peripheral is disabled by default. You have to enable it in the config before using it.
Syntax commandblock.setCommand(
  • command : string
)
Returns nil
Part of CC:Tweaked (source)
API commandblock
ExampleSet command
Set command.
Code
<nowiki>
local commandblock = peripheral.find("command")
commandblock.setCommand("kill @a")
    </nowiki>
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.