Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- vos.loadApi('core.api')
- vos.loadApi('relay.api')
- local config = Util.readTable('.tankListener')
- Relay.find()
- local active = false
- local function setActive(active)
- local iactive = active
- if config.inverse then
- iactive = not active
- end
- if iactive ~= rs.getOutput(config.side) then
- print('setting output to ' .. tostring(active))
- rs.setOutput(config.side, iactive)
- end
- Relay.send('panelUpdate', {
- uid = config.uid,
- text = config.text,
- type = 'radio',
- active = active,
- })
- end
- Message.addHandler('tankInfo', function(h, id, msg)
- local tank = msg.contents
- active = tank.amount / tank.capacity * 100 < config.limit
- printf('%s: %d%%', config.tankName, math.floor(tank.amount / tank.capacity * 100))
- setActive(active)
- end)
- Event.addHandler('heartbeat', function()
- Relay.send('getTankInfo', {
- name = config.tankName
- })
- end)
- Logger.disable()
- os.queueEvent('heartbeat')
- Event.heartbeat(30)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement