This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revision Both sides next revision | ||
tutorial:custom_oses [2015/01/14 23:41] 127.0.0.1 external edit |
tutorial:custom_oses [2015/01/17 01:22] sangar added info on how to access component proxies in BIOS |
||
---|---|---|---|
Line 123: | Line 123: | ||
component.doc | component.doc | ||
+ | component.fields | ||
component.invoke | component.invoke | ||
component.list | component.list | ||
Line 157: | Line 158: | ||
unicode.wtrunc | unicode.wtrunc | ||
``` | ``` | ||
+ | |||
+ | Accessing components in BIOS | ||
+ | ----------------- | ||
+ | Unlike in OpenOS you don't have the primary system for components in BIOS. That means you cannot just write `component.redstone.setOutput`, you have to manually create your proxy for the component first. For several reasons the proxy system is provided via the machine itself, so you can still use that. To get a proxy, use the `component.proxy` method. It expects the address of the component to wrap. You can either write that down manually, or get the the list of components using `component.list` and go from there. | ||
+ | |||
+ | For example, to get the first best redstone component, you can do the following: | ||
+ | ```lua | ||
+ | local r = component.proxy(component.list("redstone")()) | ||
+ | ``` | ||
+ | This works because `component.list` returns a Lua iterator: a function that can be called repeatedly to get the next element in whatever it iterates over, returning `nil` once there are no more elements. | ||
A few more things | A few more things |