Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RSide = "back"
- RLamp = colors.yellow
- RAlarm = colors.magenta
- RReactor = colors.green
- RTemp = colors.red
- RReset = colors.black
- RAck = colors.cyan
- REnergy = colors.lime
- monitor = peripheral.wrap("top")
- monitor.setTextScale(5)
- currOut = 0
- function onOut(color)
- currOut = colors.combine(currOut, color)
- redstone.setBundledOutput(RSide, currOut)
- end
- function offOut(color)
- currOut = colors.subtract(currOut, color)
- redstone.setBundledOutput(RSide, currOut)
- end
- function testIn(color)
- local curr = redstone.getBundledInput(RSide)
- return colors.test(curr, color)
- end
- function tst()
- monitor.setCursorPos(1,2)
- monitor.write(currOut)
- end
- function standbyState()
- offOut(RReactor)
- offOut(RLamp)
- offOut(RAlarm)
- while true do
- tst()
- if testIn(REnergy) then
- state = "running"
- break
- end
- os.pullEvent("redstone")
- end
- end
- function runningState()
- onOut(RReactor)
- offOut(RLamp)
- offOut(RAlarm)
- while true do
- tst()
- if not testIn(REnergy) then
- state = "standby"
- break
- elseif testIn(RTemp) then
- state = "error"
- break
- end
- os.pullEvent("redstone")
- end
- end
- function errorState()
- offOut(RReactor)
- onOut(RLamp)
- onOut(RAlarm)
- while true do
- tst()
- os.pullEvent("redstone")
- if testIn(RReset) then
- state = "standby"
- break
- elseif testIn(RAck) then
- state = "ack"
- break
- end
- end
- end
- function ackState()
- offOut(RReactor)
- onOut(RLamp)
- offOut(RAlarm)
- while true do
- tst()
- if testIn(RReset) then
- state = "standby"
- break
- end
- os.pullEvent("redstone")
- end
- end
- state = ""
- if testIn(RTemp) then
- state = "alarm"
- else
- if testIn(REnergy) then
- state = "running"
- else
- state = "standby"
- end
- end
- while true do
- monitor.clear()
- monitor.setCursorPos(1,1)
- monitor.write(state)
- if state == "standby" then
- standbyState()
- elseif state == "running" then
- runningState()
- elseif state == "error" then
- errorState()
- elseif state == "ack" then
- ackState()
- end
- end
Add Comment
Please, Sign In to add comment