Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for a, b in pairs(rs.getSides()) do
- if peripheral.getType(b) == "monitor" then
- mon = peripheral.wrap(b);
- break
- end
- end
- for a, b in pairs(rs.getSides()) do
- if peripheral.getType(b) == "modem" then
- rednet.open(b)
- break
- end
- end
- term.redirect(mon);
- -- stati batterie
- function ChangeState(x, y, color)
- term.setCursorPos(x, y);
- term.setTextColor(color);
- print("||");
- term.setTextColor(colors.white);
- end
- function ClearState(x, y)
- term.setCursorPos(x, y);
- term.setTextColor(colors.black);
- print("||");
- term.setTextColor(colors.white);
- end
- -- azioni a seconda della carica della batteria
- function battery(x, y)
- local red = colors.red;
- local yellow = colors.yellow;
- local green = colors.lime;
- if percent < 33 then
- ChangeState(x, y, red);
- ClearState(x, y - 1);
- ClearState(x, y - 2);
- elseif percent >= 33 and (percent <= 66) then
- ChangeState(x, y, red);
- ChangeState(x, y - 1, yellow);
- ClearState(x, y - 2);
- elseif percent >= 66 then
- ChangeState(x, y, red);
- ChangeState(x, y - 1, yellow);
- ChangeState(x, y - 2, green);
- end
- end
- function show(details, Nslot, Xstart, Ystart)
- term.setCursorPos(Xstart, Ystart);
- if (details.Name == "Adjustable Energy Storage Unit") then
- print("AESU - ", Nslot);
- elseif (details.Name == "LiFePO4 battery") then
- print("LiFePO4 - ", Nslot);
- end
- term.setCursorPos(Xstart + 1, Ystart + 1);
- term.setTextColor(colors.black);
- print("--------");
- term.setCursorPos(Xstart + 1, Ystart + 1);
- term.setTextColor(colors.white);
- print(math.floor(details.Stored));
- term.setCursorPos(Xstart + 2, Ystart + 2);
- term.setTextColor(colors.black);
- print("-------");
- term.setCursorPos(Xstart + 2, Ystart + 2);
- term.setTextColor(colors.white);
- percent = math.floor(details.StoredPercentage);
- print(percent, "%");
- battery(Xstart + 11, Ystart + 2);
- end
- function NoInput(x, y)
- term.setCursorPos(x, y);
- print("No Input");
- end
- -- controllo batterie
- while true do
- shell.run("ui");
- id, message = rednet.receive();
- Smessage = textutils.unserialize(message)
- if (Smessage.Name == "clear") then
- term.clear()
- elseif Smessage.Name == "show" then
- show(Smessage.details,Smessage.Nslot,Smessage.xPos,Smessage.yPos)
- elseif Smessage.Name == "NoInput" then
- NoInput(Smessage.xPos,Smessage.yPos)
- end
- sleep(1);
- end
Advertisement
Add Comment
Please, Sign In to add comment