-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackup-power.lua
More file actions
30 lines (26 loc) · 795 Bytes
/
backup-power.lua
File metadata and controls
30 lines (26 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
on_tick = function (event)
-- set loop to run evry x ticks. if set to 60, runs once per second.
delay = 60
--Initialisation section. This bit runs only once
if var["init"] == nil then
var["state"] = 0 -- state 0 is off. initial default.
var["init"] = true
end
-- read in variables
-- in this case 'charge' is not stored in the var[] table, meaning that it's value is lost between tick. But in this case that's fine.
charge = greennet["signal-A"]
if charge == nil then
charge = 0
end
if var["state"] == 0 then
if charge < 10 then
var["state"] = 1
end
else
if charge > 50 then
var["state"] = 0
end
end
output = {}
output["signal-P"] = var["state"]
end