Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitors = {
- peripheral.wrap("top");
- peripheral.wrap("monitor_0");
- }
- local bool loading = false;
- local onColor = colors.yellow;
- local offColor = colors.blue;
- local defaultColor = colors.white;
- --clears all monitors
- function clear()
- for i=1, #monitors do
- monitors[i].clear()
- monitors[i].setTextColor(defaultColor)
- monitors[i].setCursorPos(1,1)
- end
- end
- --goes to the next line for all monitors
- function nextline()
- for i=1, #monitors do
- local x,y = monitors[i].getCursorPos()
- local y = y + 1
- monitors[i].setCursorPos(1,y)
- end
- end
- --writes text on all monitors
- function writeText(text)
- for i=1, #monitors do
- monitors[i].write(text)
- end
- end
- --sets text color for all monitors
- function textColor(color)
- for i=1, #monitors do
- monitors[i].setTextColor(color)
- end
- end
- --sets background color for all monitors
- function backgroundColor(color)
- for i=1, #monitors do
- monitors[i].setBackgroundColor(color)
- end
- end
- function routine()
- if loading == true then
- backgroundColor(onColor);
- rs.setOutput("back",false);
- else
- backgroundColor(offColor);
- rs.setOutput("back",true);
- end
- for i=1, #monitors do
- clear();
- local x,y = monitors[i].getSize();
- y = math.floor(y/2);
- x = math.floor(x/2);
- if loading == true then
- x = x -3;
- monitors[i].setTextColor(defaultColor);
- monitors[i].setCursorPos(x,y);
- monitors[i].write("Charging");
- else
- x = x -1;
- monitors[i].setTextColor(defaultColor);
- monitors[i].setCursorPos(x,y);
- monitors[i].write("Idle");
- end
- end
- end
- while true do
- local timer = os.startTimer(1)
- local event,a1,a2,a3 = os.pullEvent()
- if event == "timer" then
- routine()
- elseif event == "monitor_touch" then
- routine()
- local x = a2;
- local y = a3;
- loading = not loading;
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment