From a95affb85dbca72352abe23b4db48a0cfe086bb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Fri, 31 Jan 2014 13:09:59 -0800 Subject: [PATCH] Updated API Component (markdown) --- API-Component.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/API-Component.md b/API-Component.md index 36fc58b..3065d7d 100644 --- a/API-Component.md +++ b/API-Component.md @@ -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