Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------Clean Terminal API---------
- --This api is used to display text
- --cleanly to the terminal
- ---------------Functions---------------
- --Used to print a title, call at
- --start
- --
- --param label: The text to display
- --param color: The int color
- function printTitle(label, color)
- --Since its the title, clear
- clearTerminal()
- --Make sure we have a color--
- if(color == nil) then
- color = colors.yellow
- end
- local withDash = "-"
- local size = term.getSize()
- size = size - string.len(label)
- size = size / 2
- --Add left dashes--
- for i = 1, size do
- withDash = withDash .. "-"
- end
- --Add label--
- withDash = withDash .. label
- --Add right dashes--
- for i = 1, size do
- withDash = withDash .. "-"
- end
- --Print the title--
- printLineWithColor(withDash, color)
- end
- --Used to print info with title
- --
- --param label: The title
- --param labelColor: Title color
- --param info: The important info
- --param infoColor: The info colors
- --param newLine: bool to newLine at end
- function printInfo(label, labelColor, info, infoColor, newLine)
- --Print the title
- printLineWithColor(label, labelColor)
- --Indent info
- infoPrint = " " .. info
- --Print
- printLineWithColor(infoPrint, infoColor)
- --New Line
- if(newLine ~= nil and newLine == true) then
- print("\n")
- end
- end
- --Used to print a line with color
- --
- --param line: The string to print
- --param color: The int color
- function printLineWithColor(line, color)
- term.setTextColor(color)
- print(line)
- term.setTextColor(colors.white)
- end
- --Used to clear the terminal
- function clearTerminal()
- term.clear()
- term.setCursorPos(1, 1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement