Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- reactorSide = "back";
- monitorSide = "right";
- updateMonitorSeconds = .1;
- minRun = 5000;
- maxRun = 9000000;
- maxTemp = 2000;
- mon = peripheral.wrap(monitorSide);
- reactor = peripheral.wrap(reactorSide);
- buttons = {
- start = { x=1, y=1, text="Start", color=colors.orange, tcolor=colors.black, click=function() start(); end },
- stop = { x=7, y=1, text="Stop", color=colors.orange, tcolor=colors.black, click=function() stop(); end },
- };
- function monitor()
- while(true) do
- mon.clear();
- mon.setTextScale(1.1);
- for k, v in pairs(buttons) do
- mon.setBackgroundColor(v.color);
- mon.setTextColor(v.tcolor);
- mon.setCursorPos(v.x, v.y);
- mon.write(v.text);
- end
- mon.setTextColor(colors.white);
- mon.setBackgroundColor(colors.black);
- mon.setCursorPos(1, 2);
- energy = reactor.getEnergyStored();
- temp1 = reactor.getFuelTemperature();
- temp2 = reactor.getCasingTemperature();
- color();
- progress1 = energy / maxRun;
- progress2 = temp1 / maxTemp;
- progress3 = temp2 / maxTemp;
- local w, h = mon.getSize();
- local oldTerm = term.redirect(mon);
- paintutils.drawFilledBox(1, 2, progress1 * w, 2, colors.yellow);
- paintutils.drawFilledBox(1, 3, progress2 * w, 3, colors.orange);
- paintutils.drawFilledBox(1, 4, progress3 * w, 4, colors.red);
- term.redirect(oldTerm);
- color();
- if(energy <= minRun) then
- start();
- elseif(energy >= maxRun) then
- stop();
- end
- if(temp1 >= maxTemp or temp2 >= maxTemp) then
- stop();
- end
- sleep(updateMonitorSeconds);
- end
- end
- function color()
- if(reactor.getActive()) then
- mon.setBackgroundColor(colors.green);
- else
- mon.setBackgroundColor(colors.combine(colors.red, colors.black));
- end
- end
- function updateCheck()
- while(true) do
- local event, side, x, y = os.pullEvent("monitor_touch");
- for k, v in pairs(buttons) do
- if(x >= v.x and x <= v.x + string.len(v.text)) then
- v.click();
- end
- end
- sleep(updateMonitorSeconds);
- end
- end
- function start()
- reactor.setActive(true);
- end
- function startP()
- start();
- print("Starting reactor.");
- end
- function stop()
- reactor.setActive(false);
- end
- function stopP()
- stop();
- print("Stopping reactor.");
- end
- function writeMon(mon, text)
- local x, y = mon.getCursorPos();
- mon.write(text);
- mon.setCursorPos(x, y + 1);
- end
- shell.run("clear");
- print("Running ComputerCraft & BigReactors System by CJ Burkey");
- parallel.waitForAll(monitor, updateCheck);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement