Commands API

The Commands API is only available to Command Computers.

Functioncommands.exec
Execute a Command and wait until the command is finished.
Syntax commands.exec(
  • command : string
)
Returns boolean sucess table output
Part of CC:Tweaked (source)
API commands
ExampleExecute a Command
Execute a Command
Code
<nowiki>
commands.exec("kill @p")
  </nowiki>
Functioncommands.execAsync
Execute a command but do not wait for it to run.
Syntax commands.execAsync(
  • command : string
)
Returns number taskID
Part of CC:Tweaked (source)
API commands
ExampleExecute a Command
Execute a Command
Code
<nowiki>
commands.execAsync("kill @p")
  </nowiki>

Commands.getBlockInfo Commands.getBlockInfos

Functioncommands.getBlockPosition
Return the location of the running Command Computer.
Syntax commands.getBlockPosition()
Returns number x number y number z
Part of CC:Tweaked (source)
API commands
ExampleGet the Position
Get the Position of the Computer and print it
Code
<nowiki>
local x, y, z = commands.getBlockPosition()
print("X:"..x.." Y:"..y.." Z:"..z)
  </nowiki>
Output
X:10 Y:100 Z:50

Commands.list

This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.