textutils.complete
From ComputerCraft Wiki
Revision as of 10:57, 19 July 2015 by Bomb Bloke (Talk | contribs)
Function textutils.complete | |
Added by ComputerCraft 1.74, textutils.complete() can be passed a partial variable name (or that of a key in a table), and returns a numerically indexed table containing strings that could be used to complete it. By default, it searches the environment used to load the textutils API, which contains its functions, and via metatables, access to _G. You can use getfenv() to obtain the environment your current script is working within (which contains its global variables, and via metatables, access to _G).
If the element found represents a table, suggestions will have "." appended to them (in which case a new call, using the old search string concatenated with such a suggestion, would return the contents of that table). If a function, "(" is appended. See also: fs.complete(), shell.complete(), shell.setCompletionFunction(), shell.completeProgram() and help.completeTopic(). | |
Syntax | textutils.complete(string object name [, table environment]) |
Returns | table completion list |
Part of | ComputerCraft |
API | textutils |
Examples
Example | |
Lists the suffixes of all keys in the current environment table beginning with "pa". | |
Code |
textutils.tabulate( textutils.complete( "pa", getfenv() ) ) |
Output | intutils. irs( rallel. (which could be concatenated to get the names of the paintutils API table, the "pairs" iterator function, and the parallel API table). |
Example | |
Lists suffixes of all keys in the colors API beginning with "li". | |
Code |
textutils.tabulate( textutils.complete( "colors.li", getfenv() ) ) |
Output | ghtBlue ghtGray me |