Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
api:component [2016/06/15 08:45]
payonel [Component API]
api:component [2018/06/15 21:47]
ldentityunknown component.list()
Line 8: Line 8:
   Calls the method with the specified name on the component with the specified address, passing the remaining arguments as arguments to that method. Returns the result of the method call, i.e. the values returned by the method. Depending on the called method'​s implementation this may throw.   Calls the method with the specified name on the component with the specified address, passing the remaining arguments as arguments to that method. Returns the result of the method call, i.e. the values returned by the method. Depending on the called method'​s implementation this may throw.
 - `component.list([filter:​string[,​ exact:​boolean]]):​function`  ​ - `component.list([filter:​string[,​ exact:​boolean]]):​function`  ​
-  Returns ​an iterator over all components currently attached to the computer, ​providing tuples of address and component type. Use it like so: `for address, componentType in component.list() do ... end`+  Returns ​a table with all components currently attached to the computer, ​with address ​as a key and component type as a valueIt also provides iterator syntax via `__call`, so you can use it like so: `for address, componentType in component.list() do ... end`  
   If `filter` is set this will only return components that contain the filter string (this is *not* a pattern/​regular expression). For example, `component.list("​red"​)` will return `redstone` components.  ​   If `filter` is set this will only return components that contain the filter string (this is *not* a pattern/​regular expression). For example, `component.list("​red"​)` will return `redstone` components.  ​
   If `true` is passed as a second parameter, exact matching is enforced, e.g. `red` will *not* match `redstone`.   If `true` is passed as a second parameter, exact matching is enforced, e.g. `red` will *not* match `redstone`.