Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Base Status Display
- Listens on base power channel and reactor status channel
- Displays stats on connected screen
- ]]--
- local base_power_status_channel = 1
- local reactor_status_channel = 2
- local wlan = peripheral.wrap('right')
- local mon = peripheral.wrap('top')
- -- Init monitor
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.white)
- mon.setCursorPos(1,1)
- mon.setTextScale(1)
- mon.clear()
- -- Returns YYY if given XXX=YYY
- function splitaftereq(s)
- return string.sub(s,string.find(s,'=')+1,-1)
- end
- wlan.open(base_power_status_channel)
- wlan.open(reactor_status_channel)
- print("Loop..")
- while true do
- local event, modemSide, senderChan, replyChan, msg, senderDist = os.pullEvent("modem_message")
- if string.match (msg,"^datetime") then
- datetime=splitaftereq(msg)
- mon.setCursorPos(1,1)
- mon.write(datetime..' ')
- end
- if string.match (msg,"^power_percent") then
- power_percent=splitaftereq(msg)
- mon.setCursorPos(1,3)
- mon.write('Base Power : '..power_percent..'% ')
- end
- if string.match (msg,"^state") then
- state=splitaftereq(msg)
- mon.setCursorPos(1,4)
- mon.write('Reactor State: '..state..' ')
- end
- if string.match (msg,"^rods") then
- rods=splitaftereq(msg)
- mon.setCursorPos(1,5)
- mon.write('Control Rods : '..rods..'% ')
- end
- if string.match (msg,"^heat") then
- heat=splitaftereq(msg)
- mon.setCursorPos(1,6)
- mon.write('Core Heat : '..heat..'C ')
- end
- if string.match (msg,"^fueltick") then
- fueltick=splitaftereq(msg)
- mon.setCursorPos(1,7)
- mon.write('Fuel Usage : '..fueltick..' mB/t ')
- end
- if string.match (msg,"^rftick") then
- rftick=splitaftereq(msg)
- mon.setCursorPos(1,8)
- mon.write('Generating : '..rftick..' KRF/t ')
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement