SHOW:
|
|
- or go back to the newest paste.
1 | - | vos.loadApi('apis.lua') |
1 | + | vos.loadApi('core.api') |
2 | vos.loadApi('relay.api') | |
3 | - | Peripheral.wrap({ type = 'wireless_modem' }) |
3 | + | |
4 | local config = Util.readTable('.tankListener') | |
5 | ||
6 | Relay.find() | |
7 | ||
8 | - | --[[ |
8 | + | |
9 | - | local me = vos.loadApi('me.api') |
9 | + | |
10 | local function setActive(active) | |
11 | - | while true do |
11 | + | local iactive = active |
12 | - | local count = me.getItemCount(13384, 0) |
12 | + | if config.inverse then |
13 | - | print(count) |
13 | + | iactive = not active |
14 | end | |
15 | - | local enabled = count < 2048 |
15 | + | if iactive ~= rs.getOutput(config.side) then |
16 | print('setting output to ' .. tostring(active)) | |
17 | - | print('setting output to ' .. |
17 | + | rs.setOutput(config.side, iactive) |
18 | - | tostring(not enabled)) |
18 | + | end |
19 | - | rs.setOutput('right', not enabled) |
19 | + | Relay.send('panelUpdate', { |
20 | - | os.sleep(30) |
20 | + | uid = config.uid, |
21 | text = config.text, | |
22 | - | --]] |
22 | + | type = 'radio', |
23 | active = active, | |
24 | }) | |
25 | end | |
26 | - | active = tank.amount / tank.capacity * 100 < 90 |
26 | + | |
27 | - | print('setting output to ' .. tostring(not active)) |
27 | + | |
28 | - | rs.setOutput('right', not active) |
28 | + | |
29 | active = tank.amount / tank.capacity * 100 < config.limit | |
30 | printf('%s: %d%%', config.tankName, math.floor(tank.amount / tank.capacity * 100)) | |
31 | setActive(active) | |
32 | end) | |
33 | - | name = 'Ethanol' |
33 | + | |
34 | Event.addHandler('heartbeat', function() | |
35 | Relay.send('getTankInfo', { | |
36 | name = config.tankName | |
37 | }) | |
38 | end) | |
39 | ||
40 | Logger.disable() | |
41 | os.queueEvent('heartbeat') | |
42 | Event.heartbeat(30) |