mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-08-03 19:17:27 -04:00
Updated API Component (markdown)
parent
d0fa85a09a
commit
a95affb85d
@ -8,8 +8,12 @@ The component API is used to access and interact with components available to a
|
||||
Gets the proxy for the primary component of the specified type. Throws an error if there is no primary component of the specified type.
|
||||
- `component.setPrimary(componentType: string, address: string)`
|
||||
Sets a new primary component for the specified component type. The address may be abbreviated, but must be valid if it is not `nil`. Triggers the `component_unavailable` and `component_available` signals if set to `nil` or a new value, respectively.
|
||||
- `component.list()`
|
||||
Returns an iterator which returns `address,type`.
|
||||
- `component.list([filter: string]): function`
|
||||
Returns an iterator which returns pairs of `address, type` for each component connected to the computer. It optionally takes a filter - if specified this will only return those components for which the filter is a substring of the component type. For example:
|
||||
```lua
|
||||
-- prints `redstone` for each attached redstone card.
|
||||
for _, name in component.list("red") do print(name) end
|
||||
```
|
||||
|
||||
Note that the component API has a metatable that allows the following syntax:
|
||||
```lua
|
||||
|
Loading…
x
Reference in New Issue
Block a user