mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-15 10:21:45 -04:00
Created API/Text (markdown)
parent
191f5c71d8
commit
323f56fc9a
15
API-Text.md
Normal file
15
API-Text.md
Normal file
@ -0,0 +1,15 @@
|
||||
This API provides some more general operations on strings and data serialization into and back from strings.
|
||||
|
||||
- `text.detab(value: string, tabWidth: number): string`
|
||||
Converts tabs in a string to spaces, while aligning the tags at the specified tab width. This is used for formatting text in `term.write`, for example.
|
||||
- `text.padRight(value: string, length: number): string`
|
||||
Pads a string with whitespace on the right up to the specified length.
|
||||
- `text.padLeft(value: string, length: number): string`
|
||||
Pads a string with whitespace on the left up to the specified length.
|
||||
- `text.trim(value: string): string`
|
||||
Removes whitespace characters from the start and end of a string.
|
||||
- `text.serialize(value: any): string`
|
||||
Generates a string from an object that can be parsed again using `text.unserialize`. The generated output is essentially Lua code. Supports basic types (nil, boolean, number, string) and tables without cycles (will error out when cycles are detected). Properly handles NaN values and infinity.
|
||||
This function can be useful for sending messages via a network card.
|
||||
- `text.unserialize(value: string): any`
|
||||
Restores an object previously saved with `text.serialize`.
|
Loading…
x
Reference in New Issue
Block a user