-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLeOS-utils.lua
68 lines (63 loc) · 1.34 KB
/
LeOS-utils.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
local w, h = term.getSize()
function buildList(...)
local list = {}
local i = 1
for v in ... do
list[i] = v
i = i + 1
end
return list
end
function encrypt(text, key)
out = {string.byte(text, 1, #text)}
for i = 1, #out do
out[i] = out[i] + key
end
return out
end
-- Writing functions
function centreWrite(text, y)
term.setCursorPos(w/2 - #text/2 + 1, y)
term.clearLine()
term.write(text)
end
function write(text, y)
term.setCursorPos(1, y)
term.clearLine()
term.write(text)
end
function writeSpec(text, x, y)
term.setCursorPos(x, y)
term.clearLine()
term.write(text)
end
function clearLine(y)
term.setCursorPos(1, y)
term.clearLine()
end
function divider(y)
term.setCursorPos(1, y)
term.clearLine()
term.write(string.rep("-", w))
end
function loadScreen()
term.clear()
centreWrite("----------", h/2-1)
centreWrite("Loading...", h/2)
centreWrite("----------", h/2+1)
end
function readAnim(file, h, offset, yPos, speed)
term.clear()
local lines = {}
for line in io.lines(file) do
lines[#lines + 1] = line
end
local len = #lines
for i=1, len, h+1 do
for j=0, h-1, 1 do
writeSpec(lines[i+j], offset, yPos+j)
end
sleep(tonumber(lines[i+h])*speed)
end
term.clear()
end