forked from Nex4rius/Nex4rius-Programme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
standby.lua
46 lines (41 loc) · 1.23 KB
/
standby.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
-- pastebin run -f 63v6mQtK
-- von Nex4rius
-- https://github.com/Nex4rius/Nex4rius-Programme
local function standby(text)
local component = require("component")
if component.isAvailable("screen") and component.isAvailable("gpu") then
local computer = require("computer")
local standby = 0.90
local display = standby
local wartezeit = 2
local screen = component.getPrimary("screen")
local gpu = component.getPrimary("gpu")
local hinten = gpu.getBackground()
local vorne = gpu.getForeground()
local function energie()
return computer.energy() / computer.maxEnergy()
end
while energie() < standby do
if energie() < display then
screen.turnOff()
os.sleep(wartezeit * 5)
else
screen.turnOn()
if text then
gpu.setBackground(0x000000)
gpu.setForeground(0xFFFFFF)
os.sleep(0.1)
require("term").clear()
os.sleep(0.1)
gpu.set(1, 1, string.format("Standby Energie: %.f%%", energie() * 100))
end
os.sleep(wartezeit)
end
end
screen.turnOn()
gpu.setBackground(hinten)
gpu.setForeground(vorne)
os.sleep(0.1)
end
end
return standby