Difference between revisions of "Textutils (API)"

From ComputerCraft Wiki
Jump to: navigation, search
m (I need to start using [Show preview].)
(Changing int to number)
Line 10: Line 10:
 
<tr><td style="width: 350px; background: #E0E0E0; padding: .4em; font-weight:bold;">Method Name</td><td style="background: #E0E0E0; padding: .4em; font-weight:bold;">Description</td></tr>
 
<tr><td style="width: 350px; background: #E0E0E0; padding: .4em; font-weight:bold;">Method Name</td><td style="background: #E0E0E0; padding: .4em; font-weight:bold;">Description</td></tr>
  
<tr style="background-color: #FFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[textutils.slowWrite]]({{type|string}} text, {{type|int}} rate)</td>
+
<tr style="background-color: #FFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[textutils.slowWrite]]({{type|string}} text, {{type|number}} rate)</td>
 
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">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).</td></tr>
 
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">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).</td></tr>
  
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[textutils.slowPrint]]({{type|string}} text, {{type|int}} rate)</td>
+
<tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[textutils.slowPrint]]({{type|string}} text, {{type|number}} rate)</td>
 
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">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.</td></tr>
 
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">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.</td></tr>
  
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[textutils.formatTime]]({{type|int}} time, {{type|boolean}} TwentyFourHour)</td>
+
<tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[textutils.formatTime]]({{type|number}} time, {{type|boolean}} TwentyFourHour)</td>
 
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Takes input ''time'' and formats it in a more readable format. If second value is true, returns time in military time; if second value is false, returns time with AM or PM. Example: print(textutils.formatTime(os.time(), false))—os.time() returns MineCraft time.</td></tr>
 
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Takes input ''time'' and formats it in a more readable format. If second value is true, returns time in military time; if second value is false, returns time with AM or PM. Example: print(textutils.formatTime(os.time(), false))—os.time() returns MineCraft time.</td></tr>
  

Revision as of 10:38, 18 July 2013

This page needs some serious TLC, stat!
Please help us by cleaning it, fixing it up, or sparing it some love.
(Reason: Needs 5 3 2 function pages, 1 function descriptions. AfterLifeLochie 02:40, 29 November 2012 (MSK))

The Textutils API is used to format and manipulate strings easily.

Grid disk.png   Textutils (API)

Method NameDescription
textutils.slowWrite(string text, number rate) 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) 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) Takes input time and formats it in a more readable format. If second value is true, returns time in military time; if second value is false, returns time with AM or PM. Example: print(textutils.formatTime(os.time(), false))—os.time() returns MineCraft time.
textutils.tabulate(table table, table table2, ...) Prints tables in an ordered form. Each table is a row, the column width is auto-adjusted.
textutils.pagedTabulate(table table, table table2, ...) Prints tables in an ordered form, like textutils.tabulate. However, it waits for confirmation before scrolling down.
textutils.pagedPrint(string text, string confirmation_lines)Prints string text onto the screen, but waits for confirmation before scrolling down.
textutils.serialize(table table) Returns a string representation of the table table for storage or transmission.
textutils.unserialize(string text) Returns a table reassembled from string text.
textutils.urlEncode(string text) 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].