Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitor = peripheral.wrap("monitor_181")
- local reactor = peripheral.wrap("right")
- local mon, monX, monY
- monX, monY = monitor.getSize()
- mon = {}
- mon.monitor,mon.X, mon.Y = monitor, monX, monY
- function clear(mon)
- term.clear()
- term.setCursorPos(1,1)
- mon.monitor.setBackgroundColor(colors.black)
- mon.monitor.clear()
- mon.monitor.setCursorPos(1,1)
- end
- function draw_text(mon, x, y, text, text_color, bg_color)
- mon.monitor.setBackgroundColor(bg_color)
- mon.monitor.setTextColor(text_color)
- mon.monitor.setCursorPos(x,y)
- mon.monitor.write(text)
- end
- function draw_text_right(mon, offset, y, text, text_color, bg_color)
- mon.monitor.setBackgroundColor(bg_color)
- mon.monitor.setTextColor(text_color)
- mon.monitor.setCursorPos(mon.X-string.len(tostring(text))-offset,y)
- mon.monitor.write(text)
- end
- function draw_text_lr(mon, x, y, offset, text1, text2, text1_color, text2_color, bg_color)
- draw_text(mon, x, y, text1, text1_color, bg_color)
- draw_text_right(mon, offset, y, text2, text2_color, bg_color)
- end
- local reactor_info
- function update()
- while true do
- clear(mon)
- --terminal
- reactor_info = reactor.getReactorInfo()
- for k, v in pairs (reactor_info) do
- print(k.. ": ".. v)
- end
- --monitor
- draw_text(mon, 2, 2, "DR H", colors.white, colors.black)
- if reactor_info.status == "online" then
- draw_text(mon, 2, 3, " ON", colors.lime, colors.gray)
- elseif reactor_info.status == "offline" then
- draw_text(mon, 2, 3, " OFF", colors.red, colors.gray)
- elseif reactor_info.status == "stopping" then
- draw_text(mon, 2, 3, "STOP", colors.orange, colors.gray)
- elseif reactor_info.status == "charging" or reactor_info.status == "charged"then
- draw_text(mon, 2, 3, " CH", colors.blue, colors.gray)
- end
- local fuelPercent, fuelColor
- fuelPercent = 100 - math.ceil(reactor_info.fuelConversion / reactor_info.maxFuelConversion * 10000)*.01
- fuelColor = colors.gray
- if fuelPercent > 40 then fuelColor = colors.green end
- if fuelPercent <= 40 and fuelPercent > 20 then fuelColor = colors.yellow end
- if fuelPercent <= 20 and fuelPercent > 11 then fuelColor = colors.orange end
- if fuelPercent <= 11 then fuelColor = colors.red end
- if fuelPercent < 90 then draw_text(mon, 3, 5, " ", fuelColor, colors.gray)
- else draw_text(mon, 3, 5, " ", fuelColor, fuelColor) end
- if fuelPercent < 70 then draw_text(mon, 3, 6, " ", fuelColor, colors.gray)
- else draw_text(mon, 3, 6, " ", fuelColor, fuelColor) end
- if fuelPercent < 50 then draw_text(mon, 3, 7, " ", fuelColor, colors.gray)
- else draw_text(mon, 3, 7, " ", fuelColor, fuelColor) end
- if fuelPercent < 30 then draw_text(mon, 3, 8, " ", fuelColor, colors.gray)
- else draw_text(mon, 3, 8, " ", fuelColor, fuelColor) end
- if fuelPercent < 11 then draw_text(mon, 3, 9, "__", fuelColor, colors.gray)
- else draw_text(mon, 3, 9, "__", fuelColor, fuelColor) end
- draw_text_right(mon, 0, 11, math.floor(fuelPercent) .. " %", fuelColor, colors.black)
- sleep(0.1)
- end
- end
- parallel.waitForAny(update)
Add Comment
Please, Sign In to add comment