This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
api [2014/07/06 16:31] vexatos |
api [2017/08/12 14:40] (current) guard13007 [Custom Libraries] guid was renamed to uuid |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | APIS | + | APIs |
==== | ==== | ||
Line 5: | Line 5: | ||
------------------ | ------------------ | ||
- | First and foremost you should get familiar with the [[http://www.lua.org/manual/5.2/manual.html|Lua reference manual]], if you are new to Lua. You will find most basic Lua functionality explained there, as well as a bunch of standard library functions. | + | First and foremost you should get familiar with the [[http://www.lua.org/manual/5.3/manual.html|Lua reference manual]], if you are new to Lua. You will find most basic Lua functionality explained there, as well as a bunch of standard library functions. |
- | OpenComputers makes an effort to largely emulate the standard library in areas that would usually interact with the host system - that being the I/O library. There are a few differences, which you can look up here: [[NonstandardLuaLibs|differences in the standard libraries]]. Most notably, the debug library is mostly unavailable, and `load` only accepts text source files, no binary / pre-compiled Lua programs (for security reasons). | + | OpenComputers makes an effort to largely emulate the standard library in areas that would usually interact with the host system - that being the I/O library. There are a few differences, which you can look up here: [[api:non-standard-lua-libs|differences in the standard libraries]]. Most notably, the debug library is mostly unavailable, and `load` only accepts text source files, no binary / pre-compiled Lua programs (for security reasons). |
- | Note that you now need to `require` all non-standard APIs (including the ones below) before you use them, i.e. all modules not listed in the [[http://www.lua.org/manual/5.2/manual.html|Lua reference manual]]. | + | These standard libraries are available in the global environment and thus are immediately available; meaning they do not need to be loaded in your scripts to be accessible. |
- | For example, instead of simple going `local rs = component.redstone`, you now need to require the component API, like so: | + | |
+ | * [[api:non-standard-lua-libs#coroutine_manipulation|coroutine]] | ||
+ | * [[api:non-standard-lua-libs#debug|debug]] | ||
+ | * [[api:non-standard-lua-libs#input_and_output_facilities|io]] | ||
+ | * [[api:non-standard-lua-libs#mathematical_functions|math]] | ||
+ | * [[api:non-standard-lua-libs#operating_system_facilities|os]] | ||
+ | * [[api:non-standard-lua-libs#Modules|package]] | ||
+ | * `print` Not a library, but a commonly used standard method for printing text to stdout. | ||
+ | |||
+ | ```lua | ||
+ | print("hello world") | ||
+ | ``` | ||
+ | |||
+ | * [[api:non-standard-lua-libs#string_manipulation|string]] | ||
+ | * [[api:non-standard-lua-libs#table_manipulation|table]] | ||
+ | |||
+ | Custom Libraries | ||
+ | ---------------- | ||
+ | |||
+ | Following is a description of the non-standard libraries, provided for convenience. | ||
+ | |||
+ | Note that you need to `require` all non-standard APIs before you use them, i.e. all modules not listed in the [[http://www.lua.org/manual/5.3/manual.html|Lua reference manual]] nor in [#standard_libraries]. For example, instead of simple going `local rs = component.redstone`, you now need to require the component API, like so: | ||
```lua | ```lua | ||
Line 20: | Line 41: | ||
local rs = mycomp.redstone | local rs = mycomp.redstone | ||
``` | ``` | ||
- | The same applies for all other APIs listed below (even Sides and Colors). | + | The same applies for all other APIs listed below (even `sides` and `colors`). |
- | + | ||
- | Custom Libraries | + | |
- | ---------------- | + | |
The standard libraries aside, OpenComputers comes with a couple of additional, built-in libraries. Here is a list of all these libraries. Note that some of these may not be usable depending on your configuration (HTTP) and context (Robot library on computers), but they'll still be there. | The standard libraries aside, OpenComputers comes with a couple of additional, built-in libraries. Here is a list of all these libraries. Note that some of these may not be usable depending on your configuration (HTTP) and context (Robot library on computers), but they'll still be there. | ||
- | - [[Buffer|Buffer]]: a Lua `FILE*` API buffer implementation for wrapping streams. | + | - [[api:buffer|buffer]]: a Lua `FILE*` API buffer implementation for wrapping streams. |
- | - [[Colors|Colors]]: a global table that allows referencing standard Minecraft colors by name. | + | - [[api:colors|colors]]: a global table that allows referencing standard Minecraft colors by name. |
- | - [[Component|Component]]: look-up and management of components attached to the computer. | + | - [[api:component|component]]: look-up and management of components attached to the computer. |
- | - [[Computer|Computer]]: information on and interactions with the computer the Lua state is running on. | + | - [[api:computer|computer]]: information on and interactions with the computer the Lua state is running on. |
- | - [[Event|Event]]: a very rudimentary event system (intended for libraries) and filtered signal pulling. | + | - [[api:event|event]]: an event system, often used by libraries, for pulling and registering handlers to signals. |
- | - [[FileSystem|FileSystem]]: abstracted interaction with file system components. | + | - [[api:uuid|uuid]]: creates long unique identifier strings in the common 8-4-4-4-12 format. |
- | - [[Internet|Internet]]: a wrapper for Internet Card functionality. | + | - [[api:fileSystem|filesystem]]: abstracted interaction with file system components. |
- | - [[Keyboard|Keyboard]]: a table of key codes by name and pressed key tracking. | + | - [[api:internet|internet]]: a wrapper for Internet Card functionality. |
- | - [[Note|Note]]: converts music notes between their real name, their MIDI code and their frequency | + | - [[api:keyboard|keyboard]]: a table of key codes by name and pressed key tracking. |
- | - [[Process|Process]]: keeps track of running programs and their environments | + | - [[api:note|note]]: converts music notes between their real name, their MIDI code and their frequency |
- | - [[Robot|Robot]]: abstracted access to robot actions. | + | - [[api:process|process]]: keeps track of running programs and their environments. |
- | - [[Serialization|Serialization]]: allows serialization of values, e.g. for sending them via the network. | + | - [[api:rc|rc]]: provides automatic program execution and service management. |
- | - [[Shell|Shell]]: working path tracking and program execution. | + | - [[api:robot|robot]]: abstracted access to robot actions. |
- | - [[Sides|Sides]]: a global table that allows referencing sides by name. | + | - [[api:serialization|serialization]]: allows serialization of values, e.g. for sending them via the network. |
- | - [[Term|Term]]: provides a simple readline implementation and text output. | + | - [[api:shell|shell]]: working path tracking and program execution. |
- | - [[Text|Text]]: provides text utilities such as serialization and tab to space conversion. | + | - [[api:sides|sides]]: a global table that allows referencing sides by name. |
- | - [[Unicode|Unicode]]: provides Unicode aware implementations of some functions in the string library. | + | - [[api:term|term]]: provides the concept of the cursor, to read and write from keyboard input and screen output, respectively. |
+ | - [[api:text|text]]: provides text utilities such as tab to space conversion. | ||
+ | - [[api:thread|thread]]: provides autonomous and non-blocking cooperative threads. | ||
+ | - [[api:transforms|transforms]]: provides helpful and advanced table manipulators. | ||
+ | - [[api:unicode|unicode]]: provides Unicode aware implementations of some functions in the string library. | ||
+ | |||
+ | |||
+ | Contents | ||
+ | ----------- | ||
+ | {{page>api:contents&noheader&noeditbutton&nouser&nofooter}} |