View difference between Paste ID: z0Xqpewh and t6YFcNFT
SHOW: | | - or go back to the newest paste.
1
_G["ks"] = {}
2
3
local tx, ty = term.getSize()
4
function ks.clear()
5
  term.clear()
6
  term.setCursorPos(1,1)
7
end
8
9
function ks.round(num)
10
  local nom = math.floor(num + 0.5)
11
  return nom
12
end
13
14
function ks.center(text,arg2,slow)
15
  if not tostring(text) then
16
    error("Error: Got "..type(text)..". Expected String")
17
  end
18
  if arg2 ~= true and tonumber(arg2) then
19
    ypos = tonumber(arg2)
20
  elseif arg2 ~= true and not tonumber(arg2) and arg2 ~= nil then
21
    error("Error: Got "..type(text)..". Expected Number or Boolean")
22
  elseif arg2 == nil then
23
    ypos = math.ceil(ty / 2)
24
  elseif arg2 == true then
25
    ypos = math.floor(ty / 2)
26
  end
27
  local text = tostring(text)
28
  term.setCursorPos(math.floor(tx/2) - math.floor(string.len(text) / 2),ypos)
29
  if arg2 == true then
30
    textutils.slowPrint(text)
31
  elseif slow == true then
32
    textutils.slowPrint(text)
33
  else
34
    print(text)
35
  end
36
  return true
37
end
38
39
function ks.setBackgroundColour(colour)
40
  local oldCol = term.getBackgroundColour()
41
  term.setBackgroundColour(colour)
42
  term.clear()
43
  term.setBackgroundColour(oldCol)
44
end
45
46
function ks.setBackgroundColor(colour)
47
  ks.setBackgroundColour(colour)
48
end