Difference between revisions of "Commands.list"

From ComputerCraft Wiki
Jump to: navigation, search
(Created page with "{{lowercase}} {{Function |name=commands.list |args= |returns={{type|table}} commands |api=commands |addon=ComputerCraft |desc=Available only to Command Computers, returns...")
 
(Example output.)
 
Line 9: Line 9:
 
|examples=
 
|examples=
 
{{Example
 
{{Example
|desc=Prints all the available commands
+
|desc=Prints all the available commands.
 
|code=local commands = '''commands.list()'''
 
|code=local commands = '''commands.list()'''
 
   
 
   
 
  [[textutils.pagedTabulate]]( commands )
 
  [[textutils.pagedTabulate]]( commands )
 +
|output= Under ComputerCraft 1.7:
 +
gamemode        give            scoreboard
 +
tp              kill            spreadplayers
 +
xp              difficulty      gamerule
 +
clear          time            help
 +
defaultgamemode weather        me
 +
tell            achievement    tellraw
 +
testforblock    seed            playsound
 +
forge          msg            spawnpoint
 +
setblock        w              toggledownfall
 +
effect          say            setworldspawn
 +
summon          testfor        ?
 +
enchant
 +
May vary under later versions.
 
}}
 
}}
 
}}
 
}}

Latest revision as of 22:47, 16 February 2015


Grid Redstone.png  Function commands.list
Available only to Command Computers, returns a numerically indexed table filled with strings representing acceptable commands for commands.exec() / commands.execAsync(). This function yields internally and might 'eat' some events, such as rednet_message or key.
Syntax commands.list()
Returns table commands
Part of ComputerCraft
API commands

Examples

Grid paper.png  Example
Prints all the available commands.
Code
local commands = commands.list()

textutils.pagedTabulate( commands )
Output Under ComputerCraft 1.7:
gamemode        give            scoreboard
tp              kill            spreadplayers
xp              difficulty      gamerule
clear           time            help
defaultgamemode weather         me
tell            achievement     tellraw
testforblock    seed            playsound
forge           msg             spawnpoint
setblock        w               toggledownfall
effect          say             setworldspawn
summon          testfor         ?
enchant
May vary under later versions.


Grid disk.png Commands API Functions
commands.exec - commands.execAsync - commands.list - commands.getBlockPosition - commands.getBlockInfo - commands.getBlockInfos