Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- local channelList = args
- local event, modemSide, senderChannel, replyChannel, message, senderDistance
- local mon0 = peripheral.wrap("monitor_2")
- local modem = peripheral.wrap("left")
- for _,num in pairs(channelList) do modem.open(tonumber(num)) end
- local amount = 0
- local cap = -1
- local prodTank = 0
- local tank_ratio = {0, 0, 0, 0}
- local delta = {0, 0, 0, 0, 0, 0}
- local energy = {0, 0, 0, 0, 0, 0}
- --local delay = {1, 1, 1, 1, 1, 1}
- mon0.clear()
- mon0.setTextScale(1.5)
- mon0.setCursorPos(1,1)
- mon0.write("Gas Turbines 01 - 03")
- --mon0.setTextScale(1)
- --mon0.setCursorPos(1,3)
- --mon0.write("Jet Fuel Production:")
- mon0.setCursorPos(1,3)
- mon0.write("Fractionator: ")
- mon0.setCursorPos(1,4)
- mon0.write("Tanks 01-04: ")
- mon0.setCursorPos(1,5)
- mon0.write("Cells 01-06:")
- local index = 1
- while true do
- event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- amount = (type(message) == "table") and (message.amount and message.amount or 0) or 0
- cap = (type(message) == "table") and (message.capacity and message.capacity or -1) or -1
- if senderChannel == tonumber(channelList[1]) then
- mon0.setCursorPos(1,3)
- mon0.clearLine()
- prodTank = math.floor(amount/cap*10000)/100
- mon0.write("Fractionator: ")
- if prodTank > 95 then mon0.setTextColor(colors.green)
- elseif prodTank > 90 then mon0.setTextColor(colors.orange)
- else mon0.setTextColor(colors.red)
- end
- mon0.write(prodTank.."%")
- mon0.setTextColor(colors.white)
- else
- if #channelList > 4 then
- index = -1
- for i = 2,5 do if senderChannel == tonumber(channelList[i]) then index = i-1; break; end; end
- if index > 0 and index < 5 then
- mon0.setCursorPos(1,4)
- mon0.clearLine()
- tank_ratio[index] = math.floor(amount/cap*100)/100
- --mon0.write(string.format("Tanks 01-04: %.2f %.2f %.2f %.2f", tank_ratio[1], tank_ratio[2], tank_ratio[3], tank_ratio[4]))
- mon0.write("Tanks 01-04: ")
- for i = 1,4 do
- if tank_ratio[i] < 0.9 then mon0.setTextColor(colors.red)
- elseif tank_ratio[i] < 0.98 then mon0.setTextColor(colors.orange)
- else mon0.setTextColor(colors.green)
- end
- mon0.write(string.format("%.2f ", tank_ratio[i]))
- end
- mon0.setTextColor(colors.white)
- end
- end
- if #channelList > 10 then
- index = -1
- for i = 6,11 do if senderChannel == tonumber(channelList[i]) then index = i-5; break; end; end
- if index > 0 and index < 7 then
- energy[index] = message.energy
- delta[index] = math.floor(message.delta/20/message.delay*100)/100
- mon0.setCursorPos(1,6)
- mon0.clearLine()
- for i = 1,6 do
- if energy[i] < 500000 then mon0.setTextColor(colors.orange)
- else mon0.setTextColor(colors.green)
- end
- -- get max energy!
- mon0.write(string.format("%.2f ", math.floor(energy[i]/500000)/100))
- end
- mon0.setCursorPos(1,7)
- mon0.clearLine()
- for i = 1,6 do
- if delta[i] < -100 then mon0.setTextColor(colors.red)
- elseif delta[i] < 0 then mon0.setTextColor(colors.orange)
- else mon0.setTextColor(colors.green)
- end
- mon0.write(string.format("%.2f ", delta[i]))
- end
- mon0.setTextColor(colors.white)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment