Base globals
The base globals are functions implemented by Lua that are always available globally.
Global functions
|
|||||||||||
Takes in a boolean value where, on the condition that it evaluates to false or nil an error is thrown with the specified message. | |||||||||||
Syntax | assert(
|
||||||||||
Returns | nil | ||||||||||
Part of | CC:Tweaked | ||||||||||
API | Base globals | ||||||||||
| |||||||||||
|
|
|||||||||||
Loads and then runs a file, using loadfile. The following is what the internals of this function look like:
function dofile(fileName)
local f = assert(loadfile(fileName))
return f()
end
|
|||||||||||
Syntax | dofile(
|
||||||||||
Returns | whatever the file returns | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | Base globals | ||||||||||
See also | loadfile | ||||||||||
|
|
|||||||||||
Throws an error with the specified message at the current line and call frame or if specified, level frames upward. | |||||||||||
Syntax | error(
|
||||||||||
Returns | nil | ||||||||||
Part of | CC:Tweaked | ||||||||||
API | Base globals | ||||||||||
| |||||||||||
|
|
|||
Returns the metatable of a table - this is whatever has been set with setmetatable. Some keys in this metatable will (if they exist) be called when certain operators are used - see the Lua Users wiki. However if the metatable contains the __metatable key the value of it will be returned instead. If there is no metatable nil is returned. | |||
Syntax | getmetatable(
|
||
Returns | table | ||
Part of | CC:Tweaked | ||
API | Base globals |
Ipairs
|
|||||||||||
Loads chunk ld (or, if ld is a function, loads the chunk returned by it) as a function and returns it. Error messages use source if available, or a representation of ld. | |||||||||||
Syntax | load(
|
||||||||||
Returns | function or nil | ||||||||||
Part of | CC:Tweaked | ||||||||||
API | Base globals | ||||||||||
|
|
|||||||||||
Takes a filename and will return a function if it's succesful. If it's not, it will return nil and a error message.
|
|||||||||||
Syntax | loadfile(
|
||||||||||
Returns | function string | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | Base globals | ||||||||||
|
Loadstring
|
|||||||||||
Gets the next index and its value of the table table starting at index. If index is nil, then it returns an initial index and value. This function returns nil if called with the last index or table is nil. However, the order that indices are returned are not in order, even if table has numerical indices. | |||||||||||
Syntax | next(
|
||||||||||
Returns | various index, various value | ||||||||||
Part of | CC:Tweaked | ||||||||||
API | Base globals | ||||||||||
|
Package Pairs
|
|||||||||||
Calls func (with arguments as parameters) in protected mode—That is, any errors thrown while the function is executing are caught and returned by the nearest enclosing pcall. | |||||||||||
Syntax | pcall(
|
||||||||||
Returns | bool false, any error | bool true, any returns | ||||||||||
Part of | Lua (source) | ||||||||||
API | Base globals | ||||||||||
|
|
|||||||||||
Prints any number of arguments (space separated) at the current cursor position in the current term. All the arguments will automatically be converted to a string using the tostring function, and concatenated, separated by spaces. This function automatically moves to the next line after writing. As well as this, it performs text wrapping, meaning if the string is too big for the term, it will continue writing on the next line. print returns the number of lines it printed. | |||||||||||
Syntax | print(
|
||||||||||
Returns | number linesPrinted | ||||||||||
Part of | CC:Tweaked (source) | ||||||||||
API | BIOS globals | ||||||||||
| |||||||||||
| |||||||||||
|
Rawequal Rawget Rawset Select Setmetatable
|
|||||||||||
Parses a number contained in a string. Useful for retrieving numeric values from user input. If str cannot be parsed as a number, the function will return nil. | |||||||||||
Syntax | tonumber(
|
||||||||||
Returns | number | nil | ||||||||||
Part of | Lua (source) | ||||||||||
API | Base globals | ||||||||||
|
|
|||||||||||
Converts x to a string.
x.."" . |
|||||||||||
Syntax | tostring(
|
||||||||||
Returns | string | ||||||||||
Part of | Lua (source) | ||||||||||
API | Base globals | ||||||||||
|
|
|||||||||||
Returns a string representing the type of the given variable. | |||||||||||
Syntax | type(
|
||||||||||
Returns | string type | ||||||||||
Part of | CC:Tweaked | ||||||||||
API | Base globals | ||||||||||
| |||||||||||
|
Xpcall
gollark: Presumably, somewhat creepy overtargeted advertising, spread it further (which I don't really like in itself), probably (if I was weird and still used Google stuff on my phone) listen into my conversations.
gollark: Thing is, what I'm attempting to say is: what sort of bad things do you think people or companies could do with leaked or bought or whatever data?
gollark: Google does, if not much else, have, as far as I know, a good track record for not letting other people get their precious datas.
gollark: I was asking Solar, but yes, that's actually sensible I guess.
gollark: Anyway, what I'm saying is, outside of selling of data to other companies (which basically just spreads it more widely, which I guess you might be against in itself?), what particular bad things are you worried non-Google companies might do with your data?
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.