Buses and components¶
The capabilities of any computer are extended using components. Components are internal or external devices attached to a computer and offer additional functionalities through Lua interfaces, usually Lua methods.
There are several types of components:
For example, a wired modem, recognized as a peripheral in CC:T, has the following methods available, documented in modem:
Some peripherals are:
Disk drives, for reading and writing floppies.
Video devices, such as monitors or terminals, for displaying information and graphics; see Video devices.
Printers, for printing information such as
Modems, for networking with other computers; see Modem networking.
Speakers, for emitting sound to the real world.
And many other things!
Components are accessible through buses. Buses are the link between computers and components. On every bus, every component has an address which is the component’s identifier on this bus, used for calling a method on this component through this bus.
Some basic buses implemented in thox are:
The built-in bus, which represents built-in components which are normally available through native APIs using dedicated component abstractions.
The ComputerCraft side bus, which represents devices directly attached to one of the sides of the computer: top, bottom, front, back, left, right.
The ComputerCraft wired bus, which represents devices attached on a wired network and connected to the computer through a wired modem.
All components are represented as such thanks to the unified thox startup API; see thox startup.
This layer is provided by APIs. On ComputerCraft, computers can interact with the Minecraft and outside worlds using those devices:
An internal hard drive, which cannot be removed. This device is interacted with in vanilla CraftOS using the fs API.
Monochrome (for basic computers and turtles) and 4-bit color (for advanced and command computers and turtles) integrated character displays. This device is interacted with in vanilla CraftOS using the term API.
Turtle members, which allows the computer to move and interact with the world and an inventory (for basic and advanced turtles). This device is interacted with in vanilla CraftOS using the turtle API.
Commands emitting module (for command computers), which allows the computer to break the fourth wall and interact directly with the Minecraft server. This device is interacted with in vanilla CraftOS using the commands API.
Redstone enablers on each side of the computer, which allows the computer to send a redstone signal with a given power on each of the six sides of the computer. This device is interacted with in vanilla CraftOS using the redstone API.
HTTP requester (if enabled in the configuration), which allows the computer to interact with web servers on the real Internet by making HTTP requests. This device is interacted with in vanilla CraftOS using the http API.
Websocket manager (if enabled in the configuration), which allows the computer to create websocket connections with servers on the real Internet. This device is interacted with in vanilla CraftOS using the http.websocket function.
ComputerCraft side bus¶
Peripherals can be attached to the computer directly, on one side. There are
six sides on basic computers:
bottom. For other devices, it’s basically a derivation of this:
Pocket computers can only have one peripheral (usually a wireless modem), which will be considered as equipped at the back.
Turtles can have up to two peripherals, on the left and on the right. They can equip and unequip a peripheral (or a tool) without any player help if necessary. Tools are not considered as peripherals.
These devices and calls are available in the CraftOS API through the peripheral API. Note however that the default API accessible to any program also checks for devices on the ComputerCraft wired bus; the native interface needs to be used for effective isolation.
ComputerCraft wired bus¶
Peripherals can also be attached to a wired network through a wired modem, not necessarily the one that is also connected to the computer. In the following configuration, the computer can access a printer and a monitor through the wired modem at its back:
In order to access the devices connected to the wired bus, one must use the peripheral methods of the modem (see the modem peripheral API), namely:
Computers connected to a wired network will, for one event emitted by a device on the wired network, receive this event as many times as it is connected to the network. For example, this computer will receive the events emitted by the monitor twice:
The OpenComputers bus is described in Component Access in the OpenComputers documentation. It is a universal bus on OpenComputers, which addresses all components using UUIDs.
Describe how the bus works, and do addresses actually affect signals, being the events in OpenComputers.
For what I’ve seen for now, most signals (but not all) use the related component address as the first argument; not all, however.
I thought there was a complete abstraction of the physical layout of the bus, but there appears to be a “slot” notion. What is that and what does it represent exactly?
See the Component API for reference.