Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ON, OFF = 15, 0
- FUEL, TEMP, WASTE, ACTIVATE = "bottom", "top", "left", "right"
- currentStatus = OFF
- command = OFF
- function check()
- if
- redstone.getAnalogInput(FUEL) == ON or
- redstone.getAnalogInput(TEMP) == ON or
- redstone.getAnalogInput(WASTE) == ON or
- command == OFF
- then
- return false
- end
- return true
- end
- function update()
- redstone.setAnalogOutput(ACTIVATE, currentStatus)
- end
- function statusToString(stat)
- if stat == 15 then
- return "ACTIVATED"
- else
- return "OK"
- end
- end
- function checkAllInputs()
- return
- redstone.getAnalogInput(FUEL),
- redstone.getAnalogInput(TEMP),
- redstone.getAnalogInput(WASTE)
- end
- rednet.open("front")
- while true do
- term.clear()
- term.setCursorPos(1,1)
- print("CHANGE STATE (ON=1/OFF=2)")
- print()
- local f, t, w = checkAllInputs()
- print("CURRENT STATUS : " .. statusToString(currentStatus))
- print("FUEL : " .. statusToString(f))
- print("TEMPERATURE : " .. statusToString(t))
- print("WASTE : " .. statusToString(w))
- sendStr =
- statusToString(currentStatus) .. ";" ..
- statusToString(f) .. ";" ..
- statusToString(t) .. ";" ..
- statusToString(w)
- repeat
- event, code, msg = os.pullEvent()--wait for event
- until
- (event == "char" and (code == "1" or code == "2")) or
- event == "redstone" or
- event == "rednet_message"
- if event == "char" then
- if code == "1" then
- command = ON
- else
- command = OFF
- end
- elseif event == "rednet_message" then
- if msg == "1" then
- command = ON
- else
- command = OFF
- end
- end
- if check() then
- currentStatus = ON
- else
- currentStatus = OFF
- end
- update()
- rednet.broadcast(sendStr)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement