mirror of
https://github.com/joe7575/techpack.git
synced 2024-11-29 10:33:47 +01:00
adapted to current API
This commit is contained in:
parent
8f7e99f76e
commit
a1a2a09cb8
@ -6,26 +6,6 @@ The SmartLine Controller provides the following API to register additional condi
|
||||
* smartline.register_condition(name, condition definition)
|
||||
* smartline.register_action(name, action definition)
|
||||
|
||||
The controller executes up to 10 rules every second. Each rule consists of:
|
||||
- two condition functions
|
||||
- one logical operator (and/or)
|
||||
- one action function
|
||||
|
||||
Depending on the operator, one or both condition functions have to return true, so that the action function is called.
|
||||
If the action is called, the action related flag (a1..a10) is automatically set and can be used in
|
||||
subsequent rules to trigger further actions without the need to evaluate both conditions again.
|
||||
|
||||
The controller executes all rules once per second. Independent how long the input condition stays 'true',
|
||||
the corresponding action will be triggered only once. The condition has to become false and then true again, to
|
||||
re-trigger/execute the action again.
|
||||
|
||||
The Controller supports the following variables:
|
||||
- binary flags (f1..f8) to store states (true/false)
|
||||
- timer variables (t1..t8), decremented each second. Used to execute actions time based
|
||||
- input values (referenced via node number) to evaluate received commands (on/off) from other tubelib nodes
|
||||
- action flags (a1..a10) )to store the action state from previous executed rules
|
||||
|
||||
All variables are stored non volatile (as long as the controller is running).
|
||||
|
||||
Each registered condition and action has the function `on_execute` which is called for each rule (every second).
|
||||
* The condition function has to return true or false, depending if the condition is true or not.
|
||||
@ -40,15 +20,12 @@ See `commands.lua` as reference. All predefined SmartLine Controller commands ar
|
||||
## Prototypes
|
||||
|
||||
```LUA
|
||||
smartline.register_condition("mymod;mycond", {
|
||||
smartline.register_condition(name, {
|
||||
title = "my condition",
|
||||
formspec = {},
|
||||
on_execute = function(data, flags, timers, inputs, actions)
|
||||
on_execute = function(data, environ)
|
||||
-- data: table with the formspec data
|
||||
-- flag: table with the flag values
|
||||
-- timers: table with the timer values
|
||||
-- inputs: table with the input values
|
||||
-- actions: table with the action values
|
||||
-- environ: not relevant here
|
||||
end,
|
||||
button_label = function(data)
|
||||
return "button label"
|
||||
@ -61,10 +38,9 @@ smartline.register_condition("mymod;mycond", {
|
||||
smartline.register_action(name, {
|
||||
title = "my action",
|
||||
formspec = {},
|
||||
on_execute = function(data, flags, timers, inputs)
|
||||
on_execute = function(data, environ, inputs)
|
||||
-- data: table with the formspec data
|
||||
-- flag: table with the flag values
|
||||
-- timers: table with the timer values
|
||||
-- environ: not relevant here
|
||||
-- inputs: table with the input values
|
||||
end,
|
||||
button_label = function(data)
|
||||
@ -73,6 +49,7 @@ smartline.register_action(name, {
|
||||
})
|
||||
```
|
||||
|
||||
The 'name' parameter should be unique. External mods should use the mod name as prefix, like "mymod_mycond".
|
||||
The 'title' is used in the main menu for the condition and action selection dialog.
|
||||
The 'formspec' table defines the condition/action related form for additional user parameters.
|
||||
It supports the following subset of the minetest formspec elements:
|
||||
@ -102,7 +79,7 @@ formspec = {
|
||||
},
|
||||
{
|
||||
type = "label",
|
||||
name = "lbl", -- not really used, but internally needed
|
||||
name = "lbl", -- not really used, but internally needed
|
||||
label = "Hint: Connect the input nodes with the controller",
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user