Difference between revisions of "Textutils (API)"

From ComputerCraft Wiki
Jump to: navigation, search
(Mild grammar fixes.)
m (Methods fix.)
Line 6: Line 6:
 
!style="background:#EEE" width="*"|Description
 
!style="background:#EEE" width="*"|Description
 
|-
 
|-
|[[textutils.slowPrint|textutils.slowPrint( text , nRate)]]
+
|[[textutils.slowPrint|textutils.slowPrint]]([[string (type)|string]] text, [[number (type)|number]] rate)
|Slowly prints the text. Only difference is, it leaves a line after it.
+
|Slowly prints the text. Only difference is, it leaves a new-line after it.
 
|-
 
|-
|[[textutils.slowWrite|textutils.slowWrite( text , nRate)]]
+
|[[textutils.slowWrite|textutils.slowWrite]]([[string (type)|string]] text, [[number (type)|number]] rate)
 
|Slowly writes the text.
 
|Slowly writes the text.
 
|-
 
|-
|[[textutils.formatTime|textutils.formatTime( time, bTwentyFourHour)]]
+
|[[textutils.formatTime|textutils.formatTime]]([[number (type)|number]] time, [[boolean (type)|bool]] TwentyFourHour)
 
|Put a time into it, and it spews it out in a different format. For example:
 
|Put a time into it, and it spews it out in a different format. For example:
local nTime = os.time()
+
local time = os.time()
  
print(textutils.formatTime( nTime, false ))
+
print(textutils.formatTime(time, false))
 
|-
 
|-
|[[textutils.tabulate|textutils.tabulate( table, table2, so on)]]
+
|[[textutils.tabulate|textutils.tabulate]]([[table (type)|table]] table, [[table (type)|table]] table2, ...)
 
|Prints tables in an ordered form. Each table is a row, columns' width is auto-adjusted.
 
|Prints tables in an ordered form. Each table is a row, columns' width is auto-adjusted.
 
|-
 
|-
|[[textutils.pagedTabulate|textutils.pagedTabulate( table, table2, so on)]]
+
|[[textutils.pagedTabulate|textutils.pagedTabulate]]([[table (type)|table]] table, [[table (type)|table]]table2, ...)
 
|<no description given>
 
|<no description given>
 
|-
 
|-
|[[textutils.pagedPrint|textutils.pagedPrint( string, lines-to-print-before-confirmation )]]
+
|[[textutils.pagedPrint|textutils.pagedPrint]]([[string (type)|string]] string, [[string (type)|string]] confirmation_lines)
 
|Prints a string onto the screen, but waits for confirmation before scrolling down.
 
|Prints a string onto the screen, but waits for confirmation before scrolling down.
 
|-
 
|-
|[[textutils.serialize|textutils.serialize( t )]]
+
|[[textutils.serialize|textutils.serialize]]([[table (type)|table]] table)
 
|Returns a string representation of the table t for storage or transmission.
 
|Returns a string representation of the table t for storage or transmission.
 
|-
 
|-
|[[textutils.unserialize|textutils.unserialize( s )]]
+
|[[textutils.unserialize|textutils.unserialize]]([[string (type)|string]] text)
 
|Returns a table reassembled from the string s.
 
|Returns a table reassembled from the string s.
 
|-
 
|-
|[[textutils.urlEncode|textutils.urlEncode( str )]]
+
|[[textutils.urlEncode|textutils.urlEncode]]([[string (type)|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: [http://www.blooberry.com/indexdot/html/topics/urlencoding.htm].
 
|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: [http://www.blooberry.com/indexdot/html/topics/urlencoding.htm].
 
|}
 
|}
  
 
[[Category:APIs]]
 
[[Category:APIs]]

Revision as of 09:13, 25 November 2012

Text utilities is used to mess around with text easier.

Its functions include:

Method name Description
textutils.slowPrint(string text, number rate) Slowly prints the text. Only difference is, it leaves a new-line after it.
textutils.slowWrite(string text, number rate) Slowly writes the text.
textutils.formatTime(number time, bool TwentyFourHour) Put a time into it, and it spews it out in a different format. For example:

local time = os.time()

print(textutils.formatTime(time, false))

textutils.tabulate(table table, table table2, ...) Prints tables in an ordered form. Each table is a row, columns' width is auto-adjusted.
textutils.pagedTabulate(table table, tabletable2, ...) <no description given>
textutils.pagedPrint(string string, string confirmation_lines) Prints a string onto the screen, but waits for confirmation before scrolling down.
textutils.serialize(table table) Returns a string representation of the table t for storage or transmission.
textutils.unserialize(string text) Returns a table reassembled from the string s.
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].