Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _G["ks"] = {}
- local tx, ty = term.getSize()
- function ks.clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- function ks.round(num)
- local nom = math.floor(num + 0.5)
- return nom
- end
- function ks.center(text,arg2,slow)
- if not tostring(text) then
- error("Error: Got "..type(text)..". Expected String")
- end
- if arg2 ~= true and tonumber(arg2) then
- ypos = tonumber(arg2)
- elseif arg2 ~= true and not tonumber(arg2) and arg2 ~= nil then
- error("Error: Got "..type(text)..". Expected Number or Boolean")
- elseif arg2 == nil then
- ypos = math.ceil(ty / 2)
- elseif arg2 == true then
- ypos = math.floor(ty / 2)
- end
- local text = tostring(text)
- term.setCursorPos(math.floor(tx/2) - math.floor(string.len(text) / 2),ypos)
- if arg2 == true then
- textutils.slowPrint(text)
- elseif slow == true then
- textutils.slowPrint(text)
- else
- print(text)
- end
- return true
- end
- function ks.setBackgroundColour(colour)
- local oldCol = term.getBackgroundColour()
- term.setBackgroundColour(colour)
- term.clear()
- term.setBackgroundColour(oldCol)
- end
- function ks.setBackgroundColor(colour)
- ks.setBackgroundColour(colour)
- end
Add Comment
Please, Sign In to add comment