Difference between revisions of "Textutils (API)"
From ComputerCraft Wiki
MKlegoman357 (Talk | contribs) (Reformatted table with {{API Table}} Template. Fixed parameters, return values, descriptions.) |
Bomb Bloke (Talk | contribs) m (textutils.complete()) |
||
Line 54: | Line 54: | ||
|[[textutils.serializeJSON]]({{type|table}}/{{type|string}}/{{type|number}}/{{type|boolean}} data) | |[[textutils.serializeJSON]]({{type|table}}/{{type|string}}/{{type|number}}/{{type|boolean}} data) | ||
|{{type|string}} serializedData | |{{type|string}} serializedData | ||
− | |Returns a JSON representation of the data <var>data</var> in a form of a {{type|string}}, mainly for [[Commands (API)|command usage]]. Also exists as textutils.seriali'''s'''eJSON. Requires CC 1.7 or later. | + | |Returns a JSON representation of the data <var>data</var> in a form of a {{type|string}}, mainly for [[Commands (API)|command usage]]. Also exists as textutils.seriali'''s'''eJSON. ''Requires CC 1.7 or later.'' |
|odd}} | |odd}} | ||
Line 62: | Line 62: | ||
|Makes a string safe to encode into a url. Spaces are replaced with <var>+</var>s. Unsafe characters such as '\', '£' and '}' are translated into ASCII code and preceded with a % for transmission. For reference visit: [http://www.blooberry.com/indexdot/html/topics/urlencoding.htm]. | |Makes a string safe to encode into a url. Spaces are replaced with <var>+</var>s. Unsafe characters such as '\', '£' and '}' are translated into ASCII code and preceded with a % for transmission. For reference visit: [http://www.blooberry.com/indexdot/html/topics/urlencoding.htm]. | ||
|}} | |}} | ||
+ | |||
+ | {{API table/row|[[textutils.complete]]({{Type|string}} partial name [, {{Type|table}} environment]) | ||
+ | |{{type|table}} matches | ||
+ | |Returns a list of strings that could be combined with the provided name to produce valid entries in the specified environment. ''Requires version 1.74 or later.'' | ||
+ | |odd}} | ||
}} | }} | ||
[[Category:APIs]] | [[Category:APIs]] |
Revision as of 11:00, 19 July 2015
The Textutils API is used to format and manipulate strings easily.
textutils (API) | ||
---|---|---|
Function | Return values | Description |
textutils.slowWrite(string text, number rate) | nil | Writes string text at current cursor position, character-by-character. Number argument rate is optional and is defaulted to 20. The higher the value of rate, the faster text is written (passing a value of 1 writes one character per second). |
textutils.slowPrint(string text, number rate) | nil | Prints string text at current cursor position, character-by-character. Number argument rate is optional and is defaulted to 20. The higher the value of rate, the faster text is printed (passing a value of 1 prints one character per second). This function also prints a newline. |
textutils.formatTime(number time, boolean twentyFourHour) | string formattedTime | Takes input time and formats it in a more readable format. If the second value is true, returns time in twenty-four hour format; if the second value is false, returns time in twelve-hour format, with AM or PM. Default for twentyFourHour is false. |
textutils.tabulate(table table/number color, table table2/number color2, ...) | nil | Prints tables in an ordered form. Each table is a row, the column width is auto-adjusted. If it encounters a number instead of a table then sets the text color to it. |
textutils.pagedTabulate(table table/number color, table table2/number color2, ...) | nil | Prints tables in an ordered form, like textutils.tabulate. However, it waits for confirmation before scrolling down. |
textutils.pagedPrint(string text [, number freeLines]) | number linesPrinted | Prints string text onto the screen, but waits for confirmation (after at least freeLines have been scrolled) before scrolling down further. Default for freeLines is 0. |
textutils.serialize(table/string/number/boolean/nil data) | string serializedData | Returns a string representation of the data data for storage or transmission. Also exists as textutils.serialise under CC 1.6 or later. |
textutils.unserialize(string serializedData) | any unserializedData | Returns the data reassembled from string serializedData. Used mainly together with textutils.serialize(). Also exists as textutils.unserialise under CC 1.6 or later. |
textutils.serializeJSON(table/string/number/boolean data) | string serializedData | Returns a JSON representation of the data data in a form of a string, mainly for command usage. Also exists as textutils.serialiseJSON. Requires CC 1.7 or later. |
textutils.urlEncode(string urlUnsafeString) | string urlSafeString | Makes a string safe to encode into a url. Spaces are replaced with +s. Unsafe characters such as '\', '£' and '}' are translated into ASCII code and preceded with a % for transmission. For reference visit: [1]. |
textutils.complete(string partial name [, table environment]) | table matches | Returns a list of strings that could be combined with the provided name to produce valid entries in the specified environment. Requires version 1.74 or later. |