Component
Documentation of the component library.
The
componentlibrary allows for interacting with OpenComputers components of all sorts. This is a native library, but the version in Halyde is improved with several new features.This library also allows for virtual components to be added or for components to be virtually removed (so they won't show up in
component.list()). This is useful for drivers and adaptation layers to create new virtual components that could smoothly interface with higher-level libraries likefilesystem.component.list([filter: string]): tableReturns a table with all the components or virtual components available, or any of typefilterif specified. Has a __call metatable iterator, so you can do things like...
for address, componentType in component.list() do
...
endcomponent.invoke(address: string, method: string, [...]): ...Invokes a function on a component.address: Address of the component.method: Function name to invoke....: Arguments to the function (or nil).component.proxy(address: string): tableReturns the proxy to a certain component. The proxy is a table of all the component's functions and properties.component.get(shortenedAddress: string): string or nil, stringFinds the full component address ofshortenedAddress. Returnsniland an error message otherwise.shortenedAddressmust be at least 3 characters long.component.virtual.add(address: string, type: string, proxy: table)Adds a virtual component withaddressandtype. When this component is proxied, returnsproxy. When this component is invoked, the function is called fromproxy.component.virtual.remove(address: string)Virtually removes a component. If this was a real component, it won't show up incomponent.list(), but it will still be able to be proxied and invoked. If this was a virtual component, it will be removed completely.component.virtual.check(address: string): boolean, table or nilReturnstrue, with information of the process that created the component (in the same format astched.getCurrentTask), if the component from the specified address is virtual. Otherwisefalse.component.doc(address:string, method:string): stringReturns the documentation string for the method with the specified name of the component with the specified address, if any. Note that you can also get this string by usingtostringon a method in a proxy, for example.component.methods(address:string):tableReturns 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.type(address:string):stringGet the component type of the component with the specified address.component.fields(address:string):stringI'm going to be honest, I have no clue what this does. It's undocumented in the official OpenComputers wiki. Just know that it exists, I guess.component.slot(address:string):stringReturn slot number which the component is installed into. Returns -1 if it doesn't otherwise make sense.
Last updated