Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Liquid Level Monitor v1.0
- by Fooman
- http://www.youtube.com/user/Foooman
- Intended for use with Railcraft Steam Boilers not being fed by Aqueous Accumulators.
- ]]--
- --Side of Computer with Nuclear Information Reader
- local nuclearReaderSide = "top"
- --Side of Computer with Howler Alarm
- local howlerAlarmSide = "back"
- --Time interval (seconds) between updates
- local updateInterval = 5
- --Amount of Liquid (amount/capacity) to trigger alarm
- local alarmTrigger = 0.5
- local lCapacity
- local lAmount
- nr = peripheral.wrap(nuclearReaderSide)
- function getLiquid()
- local a,b,c, info = nr.get(1)
- --Error on bad sensor kit
- if b ~= "OK" then error("bad sensor kit: "..b) end
- for system, status in pairs(info) do
- status = tostring(status)
- if system == "capacity" then
- lCapacity = status
- elseif system == "amount" then
- lAmount = status
- print(status)
- end
- end
- end
- function alarmTrig()
- if (lAmount/lCapacity) <= alarmTrigger then
- rs.setOutput(howlerAlarmSide, true)
- else
- rs.setOutput(howlerAlarmSide, false)
- end
- end
- --Operation
- term.clear()
- local updateTimer = os.startTimer(0.05)
- while true do
- event, param1, param2, param3 = os.pullEvent()
- if event == "timer" then
- getLiquid()
- alarmTrig()
- updateTimer = os.startTimer(updateInterval)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement