-
Notifications
You must be signed in to change notification settings - Fork 434
Home
For those that don't like images: the wiki has moved to a new place, http://ocdoc.cil.li/.
This wiki will no longer be updated.
This wiki is organized several parts:
- General information (this page).
- Block and item documentation.
- Lua API documentation.
- Component API documentation.
- Tutorials.
OpenComputers is a mod that adds computers and robots into the game that can be programmed in Lua 5.2. It takes ideas from a couple of other mods such as ComputerCraft, StevesCarts and Modular Powersuits to create something new and - hopefully - interesting. Here a few key points.
Programs will resume where they were stopped when the chunk with the computer they run on was unloaded and reloaded later. This is particularly useful for single player, servers where you can't spam chunk loaders and last but not least Redstone in Motion frames. OpenComputers achieves this by persisting the actual call stacks of all running coroutines. This is the reason OpenComputers doesn't use a Java implementation of the Lua VM, since those all use Java threads as far I'm aware, which cannot be persisted. Therefore:
Important: OpenComputers comes with a native library - the Eris library, specifically. This includes the official Lua VM implementation. Currently the library is included in the mod for Windows, Mac OS X and Linux. Note that, only the server requires the library. Clients do not. All Lua code is executed purely on the server. If the library is not available for your system, the mod will fall back to LuaJ, a Java implementation of Lua. In fallback mode computers will not persist, and memory will not be limited.
You can add and remove components such as expansion cards and hard drives. This means it takes a little more effort to get your first computer, but adds a whole new level of flexibility. For example, you could build a pure "server" by having a computer that only has a network card, but no graphics card, Or a "workstation" that contains large amounts of graphics processing, networking, I/O and RAM. Etc.
Besides the obvious limitation of disk space, computers also have a limited amount of RAM. You'll actually have to keep this in mind when writing your programs, since low end computers can run out of memory pretty quickly.
This also makes computers quite server-friendly, since it's less likely for them to strain the server unduly. A few more limits are in place to further enhance server performance: OpenComputers does not have to spawn a new thread for each coroutine. Instead, it uses a fixed number of low-priority worker threads to drive all currently loaded and running computers. Computers are also forced to yield regularly (per default within one second) to avoid them blocking the worker threads. If they fail to do so, the computer will "crash".
Computers and certain components need power to operate. For example, computers and screens require a constant amount of energy per tick to continue running / displaying. If there is not enough power, computers will crash / stop. Graphics cards consume energy when modifying the screen they are bound to, the amount of energy being consumed depending on the size of the area that is being changed. Wireless network cards consume energy when sending wireless messages, based on the used signal strength. Robots use energy to move and perform other actions.
There is - except for a robot upgrade - no built-in mechanic for generating power at this point, so you'll want to use this mod together with others. OpenComputers can convert power from BuildCraft, IndustrialCraft², ThermalExpansion 3 and Universal Electricity using the Power Converter block.
In OpenComputers there are item and block components, i.e. "things that can be seen from Lua".
Block components can be seen from computers that are connected to the block by being next to it, or indirectly by any number of other blocks from this mod. If you know how Applied Energistics powers its blocks, that's basically how it is here, too. For example, if a screen is next to a power distributor which is next to a computer, the computer can still see the screen, because it is connected to it via the power distributor. The cheapest way of connecting blocks this way is the cable block.
Item components can usually be only seen by the computer they're installed in. An exception to that rule are floppy disks in disk drives, which behave like a block component.
See the page on component interaction to learn how to communicate with components from Lua.
Almost every aspect of the mod can be tweaked via the configuration file. Not a fan of computers requiring power to run? Set their running cost to zero. Don't want power to play a role at all? Disable it completely! Think robots move too slow? Make 'em faster. Want bigger multi-block screens? Increase the maximum size. Just have a look at the default configuration file to see all the options. They are hopefully well enough documented.