-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenCFunctions.lua
More file actions
51 lines (46 loc) · 1.24 KB
/
Copy pathopenCFunctions.lua
File metadata and controls
51 lines (46 loc) · 1.24 KB
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
require "APIs"
require "components"
--functions
function splitString(inputStr, sep)
if sep == nil then
sep = "%s"
end
local i = 1
local t={}
for str in string.gmatch(inputStr, "([^"..sep.."]+)") do
table.insert(t, i, str)
i = i + 1
end
return t
end
function printCentered(str, w, h)
local str = tostring(str)
local width, height = gpu.getResolution()
term.setCursor((width + w - string.len(str)) / 2, (height - h) / 2)
term.write(str)
end
function printWidthCentered(str, h)
local width, height = gpu.getResolution()
local str = tostring(str)
term.setCursor((width - string.len(str)) / 2, h)
term.write(str)
end
function slowPrint(str, time)
local str = tostring(str)
local length = string.len(str)
for i=0, length do
term.write(string.sub(str, i, i))
os.sleep(time)
end
end
function getScreenTier()
local width, height = gpu.maxResolution()
if width == 160 and height == 50 then
screenTier = 3
elseif width == 80 and height == 25 then
screenTier = 2
elseif width == 50 and height == 16 then
screenTier = 1
end
return screenTier
end