The component API is used to access and interact with components available to a computer. Also see the page on component interaction.
component.doc(address:string, method:string): stringtostring on a method in a proxy, for example tostring(component.screen.isOn).component.invoke(address:string, method:string[, ...]): ...component.list([filter:string[, exact:boolean]]):function__call, so you can use it like so: for address, componentType in component.list() do ... endfilter 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.true is passed as a second parameter, exact matching is enforced, e.g. red will not match redstone.component.methods(address:string):tablecomponent.proxy(address:string):tableinvoke). This is what's used to generate 'primaries' of the individual component types, i.e. what you get via component.blah.component.proxy(component.list("redstone")()).getInput(sides.north), which gets you a proxy for the first redstone component returned by the component.list iterator, and then calls getInput on it.type with the component's type name, and address with the component's address.component.type(address:string):stringcomponent.slot(address:string):stringcomponent.fields(address:string):stringcomponent.get(address: string[, componentType: string]): string | (nil, string)nil and an error message otherwise. Optionally filters by component type.component.isAvailable(componentType: string): booleancomponent.getPrimary(componentType: string): tablecomponent.setPrimary(componentType: string, address: string)nil. Triggers the component_unavailable and component_available signals if set to nil or a new value, respectively.
local component = require("component") local rs0 = component.getPrimary("redstone") local rs1 = component.redstone -- syntactic sugar print(rs0 == rs1) -- true