Difference between revisions of "CommandBlock.runCommand"
From ComputerCraft Wiki
MKlegoman357 (Talk | contribs) (Added commandBlock.runCommand) |
MKlegoman357 (Talk | contribs) (Fixed return parameters, improved example) |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
{{Function | {{Function | ||
− | |name=commandBlock.runCommand | + | |name=''commandBlock''.runCommand |
|api=Command Block | |api=Command Block | ||
− | |returns={{type| | + | |returns={{type|boolean}} success [<nowiki/>, {{type|string}} error] |
|addon=ComputerCraft | |addon=ComputerCraft | ||
− | |desc=Runs the command inside the Command Block previously set by manually editing it or by using [[commandBlock.setCommand]]() | + | |desc=Runs the command inside the Command Block previously set by manually editing it or by using [[commandBlock.setCommand|''commandBlock''.setCommand]](). In case of error, returns <var>false</var> + an error message <var>error</var>. |
|examples={{Example | |examples={{Example | ||
|desc=Sets the command to ''toggledownfall'' and runs it (assuming the Command Block is on the left of the [[Computer]]). | |desc=Sets the command to ''toggledownfall'' and runs it (assuming the Command Block is on the left of the [[Computer]]). | ||
− | |code=local commandBlock = [[peripheral.wrap]]("left") | + | |code=local commandBlock = [[peripheral.wrap]]("left") |
+ | |||
+ | [[commandBlock.setCommand]]( "toggledownfall" ) | ||
+ | '''commandBlock.runCommand()''' | ||
}} | }} | ||
}} | }} | ||
[[Category:Lua_Core_Functions]] | [[Category:Lua_Core_Functions]] |
Latest revision as of 19:29, 16 February 2015
Function commandBlock.runCommand | |
Runs the command inside the Command Block previously set by manually editing it or by using commandBlock.setCommand(). In case of error, returns false + an error message error. | |
Syntax | commandBlock.runCommand() |
Returns | boolean success [, string error] |
Part of | ComputerCraft |
API | Command Block |
Examples
Example | |
Sets the command to toggledownfall and runs it (assuming the Command Block is on the left of the Computer). | |
Code |
local commandBlock = peripheral.wrap("left") commandBlock.setCommand( "toggledownfall" ) commandBlock.runCommand() |