Update README

Signed-off-by: Rahix <rahix@rahix.de>
dev
rahix 7 years ago
parent 3c4920489a
commit 126d420e3c

@ -1,21 +1,21 @@
oc-basecontrol oc-basecontrol
============== ==============
oc-basecontrol is a OpenComputers generic base control library. oc-basecontrol is an OpenComputers generic base control library.
## Documentation ## ## Documentation ##
Load oc-basecontrol into your application: Load oc-basecontrol into your application:
```lua ```lua
bc = require("bc"):init("<master-address>") bc = require("bc"):init(<nouns>, <verbs>)
``` ```
where `<master-address>` is the address of you networks master. where `<nouns>` is a table containing all nouns (described later) and their
The master is only required to download the base structure file. initial value and `<verbs>` is a table containing all verbs and their callbacks.
The basic idea behind basecontrol is, that network node have a set of **nouns**, The basic idea behind basecontrol is, that network nodes have a set of **nouns**,
which represent different values. A computer near a reactor for example could have which represent different values. A computer near a reactor for example could have
a noun called `power-output`. Network nodes also have **verbs**, actions that other a noun called `power-output`. Network nodes also have **verbs**, actions that other
nodes can perform. The reactor comuputer could have a `shutdown` verb for example. nodes can perform. The reactor computer could have a `shutdown` verb for example.
The `bc` object has the following methods to interface with verbs and nouns: The `bc` object has the following methods to interface with verbs and nouns:
```lua ```lua
@ -27,9 +27,6 @@ bc:set_noun("<noun>", value)
-- Call a verb on it's network node -- Call a verb on it's network node
bc:call_verb("<verb>", param) bc:call_verb("<verb>", param)
-- Register a handler for verbs on the current machine
bc:on_verb("<verb>", function handler)
``` ```
Additionally, there is Additionally, there is
@ -37,8 +34,8 @@ Additionally, there is
id = bc:listen_noun("<noun>", event_type, event_arg, function callback) id = bc:listen_noun("<noun>", event_type, event_arg, function callback)
``` ```
which is used to register asynchroneous callbacks on noun changes. which is used to register asynchroneous callbacks on (possibly remote) noun
`event_type` is one of changes. `event_type` is one of
* `onchange` => whenever the value changes, `event_arg` is ignored * `onchange` => whenever the value changes, `event_arg` is ignored
* `onrising` => whenever the value gets bigger, `event_arg` is ignored * `onrising` => whenever the value gets bigger, `event_arg` is ignored
@ -54,7 +51,7 @@ bc:listen_cancel("<noun>", id)
``` ```
## Testing ## ## Testing ##
Testing is done using the "fake" backend and typing Testing is done using a "fake" backend and typing
```console ```console
$ ./lunit test_bc.lua $ ./lunit test_bc.lua
``` ```

Loading…
Cancel
Save