Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- gpu = component.proxy(component.list("gpu")());
- modem = component.proxy(component.list("modem")());
- mfe = component.proxy(component.list("mfsu")());
- red = component.proxy(component.list("redstone")());
- chest = component.proxy(component.list("iron")());
- boiler = component.proxy(component.list("boiler_firebox")());
- turbine = component.proxy(component.list("steam_turbine")());
- cenergy = 0;
- fenergy = 0;
- level = 0;
- bmode = "AUTO";
- bmin = 20;
- bmax = 80;
- bstate = 0;
- pstate = 1;
- msg = {};
- preen = 0;
- coalres = 0;
- flCoal = 0;
- flEnergy = 0;
- flTurbine = 0;
- modem.open(451);
- while true do
- gpu.setResolution(25, 8);
- cenergy = mfe.getEUStored();
- fenergy = mfe.getEUCapacity();
- level = cenergy/fenergy*100;
- if level == nil then level = 0; end
- gpu.fill(1, 1, 25, 8, " ");
- gpu.set(1, 1, "STORED: "..tostring(cenergy));
- gpu.set(1, 2, "TOTAL: "..tostring(fenergy));
- gpu.set(9, 3, tostring(math.floor(level)).."%");
- gpu.set(2, 4, "|");
- gpu.set(23, 4, "|");
- gpu.fill(3, 4, level/5, 1, "*");
- gpu.set(1, 5, "eU/s:");
- gpu.set(9, 5, tostring(cenergy-preen));
- preen = cenergy;
- gpu.set(1, 6, "BOILER MODE:");
- gpu.set(15, 6, bmode);
- if pstate == 1 then
- red.setOutput(4, 15);
- pstate=2;
- elseif pstate == -1 then
- red.setOutput(4, 0);
- pstate = -2;
- end
- if bmode == "AUTO" then
- if bstate == 0 and level < bmin then
- red.setOutput(5, 0);
- bstate = 1;
- elseif bstate == 1 and level > bmax then
- red.setOutput(5, 15);
- bstate = 0;
- end
- elseif bmode == "ON" and bstate == 0 then
- red.setOutput(5, 0);
- bstate = 1;
- elseif bmode == "OFF" and bstate == 1 then
- red.setOutput(5, 15);
- bstate = 0;
- else bmode = "AUTO";
- end
- if bstate == 1 then
- gpu.set(1, 7, "BOILER: HEATING UP");
- else
- gpu.set(1, 7, "BOILER: COOLING DOWN");
- end
- if pstate == 2 then
- gpu.set(1, 8, "MASTER POWER ON");
- elseif pstate == 2 then
- gpu.set(1, 8, "MASTER POWER OFF");
- end
- coalres = 0;
- for i=1,chest.getInventorySize() do
- if chest.getStackInSlot(i) ~= nil then
- coalres = coalres + chest.getStackInSlot(i).qty;
- end
- end
- if level <= 1 and flEnergy < 1 then
- modem.broadcast(911, 'eng', 'EMERG', 'ENERGY CRITICAL');
- flEnergy = 1;
- elseif flEnergy > 0 and level > 2 then
- flEnergy = 0;
- end
- if coalres <= 256 and flCoal < 1 then
- modem.broadcast(911, 'eng', 'Prior', 'COAL LOW');
- flCoal = 1;
- elseif flCoal > 0 and coalres > 320 then
- flCoal = 0;
- end
- if turbine.getTurbineRotorStatus() < 3 and flTurbine < 1 then
- modem.broadcast(911, 'eng', 'Prior', 'TURBINE LOW');
- flTurbine = 1;
- elseif flTurbine > 0 and turbine.getTurbineRotorStatus() > 3 then
- flTurbine = 0;
- end
- msg = {computer.pullSignal(1)};
- if msg[1] == "modem_message" then
- computer.beep(600, 0.5);
- if msg[6] == "engineering" then
- if msg[7] == "boiler" then
- bmode = msg[8];
- if tonumber(msg[9]) ~= nil then
- bmin = tonumber(msg[9]);
- end
- if tonumber(msg[10]) ~= nil then
- bmax = tonumber(msg[10]);
- end
- modem.send(msg[3], 451, "engreply", "boilerACK", bmode, bmin, bmax);
- modem.broadcast(999, 'eng', '_log_', "New boiler mode: "..bmode);
- computer.beep(800, 0.5);
- elseif msg[7] == "power" then
- pstate = tonumber(msg[8]);
- modem.send(msg[3], 451, "engreply", "powerACK", pstate);
- modem.broadcast(999, 'eng', 'log', "Power changed to: "..tostring(pstate));
- computer.beep(800, 0.5);
- elseif msg[7] == "rep1" then
- modem.send(msg[3], 451, "engreply_rep1", cenergy, fenergy, pstate, coalres, turbine.getTurbineRotorStatus());
- computer.beep(800, 0.5);
- elseif msg[7] == "rep2" then
- modem.send(msg[3], 451 , "engreply_rep2", bstate, bmode, bmin, bmax);
- computer.beep(800, 0.5);
- elseif msg[7] == "rep3" then
- modem.send(msg[3], 451, "engreply_rep3", boiler.isBurning(), boiler.getTemperature(), turbine.getTurbineOutput());
- computer.beep(800, 0.5);
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment