commands.execAsync
From ComputerCraft Wiki
Revision as of 17:18, 16 February 2015 by MKlegoman357 (Talk | contribs) (Created page with "{{lowercase}} {{Function |name=commands.execAsync |args={{type|string}} command |returns={{type|number}} taskID |api=commands |addon=ComputerCraft |desc=Available only to Co...")
| Available only to Command Computers, executes the specified command, but doesn't yield. Queues a "task_complete" event after the command is executed. You can use the taskID returned by this function to identify the "task_complete" event. | |
| Syntax | commands.execAsync(string command) |
| Returns | number taskID |
| Part of | ComputerCraft |
| API | commands |
Examples
| Says 'Hello' to the player, closest to the Command Computer. | |
| Code |
commands.execAsync( "say @p Hello" ) |
| Checks if there are any players around the Command Computer in 2 block radius. | |
| Code |
local radius = 2 local taskID = commands.execAync( "testfor @a[r=" .. radius .. "]") local arePlayersAround repeat local event, id, success, executed, error = os.pullEvent( "task_complete" ) arePlayersAround = success and executed until id == taskID if arePlayersAround then print( "There is one or more players around me." ) else print( "There are no players around me." ) end |
| |
|---|
| commands.exec - commands.execAsync - commands.list - commands.getBlockPosition - commands.getBlockInfo - commands.getBlockInfos |