Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local chan=39701
- local monitor=peripheral.wrap("monitor_6")
- local modem=peripheral.wrap("left")
- modem.open(chan)
- local width,height=monitor.getSize()
- monitor.clear()
- monitor.setBackgroundColor(colors.purple)
- monitor.setTextColor(colors.yellow)
- monitor.setCursorPos(1,1)
- monitor.write("Energy Cell Management"..string.rep(" ",width-#"Energy Cell Management"))
- monitor.setTextScale(.5)
- local writeFormat={[1]={"Maximum Energy Stored: "," RF"},[2]={"Energy Stored: "," RF"},[3]={"Energy Percent: ","%"}}
- local reporters={}
- while true do
- monitor.setBackgroundColor(colors.black)
- monitor.setTextColor(colors.white)
- for row=1,height do
- monitor.write(string.rep(" ",width))
- end
- local totalData={0,0,0}
- local event={os.pullEvent()}
- if event[1]=="monitor_touch" then
- print("Monitor touch detected")
- if quit.clicked(event[3],event[4])==true then
- monitor.clear()
- break
- end
- elseif event[1]=="key" and event[2]==keys.q then
- monitor.clear()
- break
- elseif event[1]=="modem_message" and event[3]==chan then
- local data={}
- --print(event[5])
- for word in string.gmatch(event[5],"[^%s]+") do
- table.insert(data,word)
- end
- reporters[data[1]]={[1]=data[2],[2]=data[3],[3]=data[4]}
- end
- local maxLength=#writeFormat[1][1]
- local currentRow=3
- for key,value in pairs(reporters) do
- monitor.setCursorPos(1,currentRow)
- monitor.write(key..": ")
- currentRow=currentRow+1
- for key2,value2 in ipairs(reporters[key]) do
- monitor.setCursorPos(3,currentRow)
- monitor.write(string.rep(" ",maxLength-#writeFormat[key2][1])..writeFormat[key2][1]..value2..writeFormat[key2][2])
- totalData[key2]=totalData[key2]+value2
- currentRow=currentRow+1
- end
- currentRow=currentRow+1
- end
- totalData[3]=math.floor(100*(totalData[2]/totalData[1]))
- monitor.setCursorPos(1,currentRow)
- monitor.write("Total Energy Grid Information: ")
- currentRow=currentRow+1
- for i=1,3 do
- monitor.setCursorPos(3,currentRow)
- monitor.write(string.rep(" ",maxLength-#writeFormat[i][1])..writeFormat[i][1]..totalData[i]..writeFormat[i][2])
- currentRow=currentRow+1
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment