Differences

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

Link to this comparison view

Next revision
Previous revision
Next revision Both sides next revision
api:component [2014/07/07 10:31]
vexatos created
api:component [2015/01/14 23:40]
127.0.0.1 external edit
Line 1: Line 1:
 +Component API
 +=============
 The component API is used to access and interact with components available to a computer. Also see [[:​component:​component_access|the page on component interaction]]. The component API is used to access and interact with components available to a computer. Also see [[:​component:​component_access|the page on component interaction]].
  
Line 5: Line 7:
 - `component.invoke(address:​string,​ method:​string[,​ ...]): ...`  ​ - `component.invoke(address:​string,​ method:​string[,​ ...]): ...`  ​
   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]):​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 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`
-  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`. 
 +- `component.methods(address:​string):​table` ​  
 +  Returns a table with the names of all methods provided by the component with the specified address. The names are the keys in the table, the values indicate whether the method is called directly or not.
 - `component.proxy(address:​string):​table`  ​ - `component.proxy(address:​string):​table`  ​
   Gets a '​proxy'​ object for a component that provides all methods the component provides as fields, so they can be called more directly (instead of via `invoke`). This is what's used to generate '​primaries'​ of the individual component types, i.e. what you get via `component.blah`.  ​   Gets a '​proxy'​ object for a component that provides all methods the component provides as fields, so they can be called more directly (instead of via `invoke`). This is what's used to generate '​primaries'​ of the individual component types, i.e. what you get via `component.blah`.  ​