Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sleep(1)
- print("waiting for connection...")
- local modem = peripheral.wrap("back")
- local maxVal = 0
- local minVal = 0
- local input = 0
- local output = 0
- local delta = 0
- local capper = 0
- function clear()
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- end
- -- Round Decimal Numbers
- function roundNumber(num, n)
- local mult = 10^(n or 0)
- return math.floor(num * mult + 0.5) / mult
- end
- while true do
- modem.closeAll()
- modem.open(1)
- event, side, frequency, replyFrequency, message, distance = os.pullEvent("modem_message")
- maxVal = message
- modem.closeAll()
- modem.open(2)
- event, side, frequency, replyFrequency, message, distance = os.pullEvent("modem_message")
- minVal = message
- modem.closeAll()
- modem.open(3)
- event, side, frequency, replyFrequency, message, distance = os.pullEvent("modem_message")
- input = message
- modem.closeAll()
- modem.open(4)
- event, side, frequency, replyFrequency, message, distance = os.pullEvent("modem_message")
- output = message
- modem.closeAll()
- modem.open(5)
- event, side, frequency, replyFrequency, message, distance = os.pullEvent("modem_message")
- delta = message
- modem.closeAll()
- modem.open(6)
- event, side, frequency, replyFrequency, message, distance = os.pullEvent("modem_message")
- capper = message
- modem.closeAll()
- term.clear()
- term.setCursorPos(2,1)
- term.setTextColor(colors.yellow)
- term.write("Capacity:")
- term.setCursorPos(2,3)
- term.write("Input: ")
- term.setCursorPos(2,5)
- term.write("Output: ")
- term.setCursorPos(2,7)
- term.write("Delta: ")
- --line 1/2
- term.setCursorPos(2,2)
- if maxVal < 1000 then
- term.write(roundNumber(((math.floor(minVal))/1), 2).."/"..(roundNumber((maxVal/1), 2)).." RF")
- else if maxVal < 1000000 then
- term.write(roundNumber(((math.floor(minVal))/1000), 2).."/"..(roundNumber((maxVal/1000), 2)).." KRF")
- else if maxVal < 1000000000 then
- term.write(roundNumber(((math.floor(minVal))/1000000), 2).."/"..(roundNumber((maxVal/1000000), 2)).." MRF")
- else if maxVal < 1000000000000 then
- term.write(roundNumber(((math.floor(minVal))/1000000000), 2).."/"..(roundNumber((maxVal/1000000000), 2)).." GRF")
- else if maxVal < 1000000000000000 then
- term.write(roundNumber(((math.floor(minVal))/1000000000000), 2).."/"..(roundNumber((maxVal/1000000000000), 2)).." TRF")
- else
- term.write(roundNumber(((math.floor(minVal))/1000000000000000), 2).."/"..(roundNumber((maxVal/1000000000000000), 2)).." PRF")
- end
- end
- end
- end
- end
- --Line 3/4
- term.setCursorPos(2,4)
- if input < 1000 then
- term.write(roundNumber(((math.floor(input))/1), 2).." RF/T")
- else if input < 1000000 then
- term.write(roundNumber(((math.floor(input))/1000), 2).." KRF/T")
- else if input < 1000000000 then
- term.write(roundNumber(((math.floor(input))/1000000), 2).." MRF/T")
- else if input < 1000000000000 then
- term.write(roundNumber(((math.floor(input))/1000000000), 2).." GRF/T")
- else if input < 1000000000000000 then
- term.write(roundNumber(((math.floor(input))/1000000000000), 2).." TRF/T")
- else
- term.write(roundNumber(((math.floor(input))/1000000000000000), 2).." PRF/T")
- end
- end
- end
- end
- end
- --Line 5/6
- term.setCursorPos(2,6)
- if output < 1000 then
- term.write(roundNumber(((math.floor(output))/1), 2).." RF/T")
- else if output < 1000000 then
- term.write(roundNumber(((math.floor(output))/1000), 2).." KRF/T")
- else if output < 1000000000 then
- term.write(roundNumber(((math.floor(output))/1000000), 2).." MRF/T")
- else if output < 1000000000000 then
- term.write(roundNumber(((math.floor(output))/1000000000), 2).." GRF/T")
- else if output < 1000000000000000 then
- term.write(roundNumber(((math.floor(output))/1000000000000), 2).." TRF/T")
- else
- term.write(roundNumber(((math.floor(output))/1000000000000000), 2).." PRF/T")
- end
- end
- end
- end
- end
- --Line 7/8
- if delta > 0 then
- term.setTextColor(colors.lime)
- else
- term.setTextColor(colors.red)
- end
- term.setCursorPos(2,8)
- if delta < -1000000000000000 then
- term.write(roundNumber(((math.floor(delta))/1000000000000000), 2).." PRF/T")
- else if delta < -1000000000000 then
- term.write(roundNumber(((math.floor(delta))/1000000000000), 2).." TRF/T")
- else if delta < -1000000000 then
- term.write(roundNumber(((math.floor(delta))/1000000000), 2).." GRF/T")
- else if delta < -1000000 then
- term.write(roundNumber(((math.floor(delta))/1000000), 2).." MRF/T")
- else if delta < -1000 then
- term.write(roundNumber(((math.floor(delta))/1000), 2).." KRF/T")
- else if delta < 1000 then
- term.write(roundNumber(((math.floor(delta))/1), 2).." RF/T")
- else if delta < 1000000 then
- term.write(roundNumber(((math.floor(delta))/1000), 2).." KRF/T")
- else if delta < 1000000000 then
- term.write(roundNumber(((math.floor(delta))/1000000), 2).." MRF/T")
- else if delta < 1000000000000 then
- term.write(roundNumber(((math.floor(delta))/1000000000), 2).." GRF/T")
- else if delta < 1000000000000000 then
- term.write(roundNumber(((math.floor(delta))/1000000000000), 2).." TRF/T")
- else
- term.write(roundNumber(((math.floor(delta))/1000000000000000), 2).." PRF/T")
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement