Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local isAdvanced
- local function init()
- isAdvanced = term.isColor()
- end
- function colorWrite(message, color)
- init()
- if not color then
- color = colors.white
- end
- if isAdvanced then
- term.setTextColor(color)
- end
- write(message)
- if isAdvanced then
- term.setTextColor(colors.white)
- end
- end
- function highlightWrite(message, color, doFillLine)
- local whitespaces = ""
- local posOfNewline
- local doBreak = false
- init()
- if not color then
- color = colors.black
- end
- if isAdvanced then
- term.setBackgroundColor(color)
- end
- if doFillLine then
- while true do
- posOfNewline = message:find("\n")
- if doBreak then
- break
- end
- if posOfNewline == nil then
- posOfNewline = message:len() + 1
- doBreak = true
- end
- for i = 1, term.getSize() - message:sub(1, posOfNewline - 1):len()
- % term.getSize() do
- whitespaces = whitespaces.." "
- end
- message = message:sub(1, posOfNewline - 1)..whitespaces..
- message:sub(posOfNewline + 1, message:len())
- end
- end
- write(message)
- if isAdvanced then
- term.setBackgroundColor(colors.black)
- end
- end
- function colorWriteWithHighlight(message, textColor, highlightColor, doFillLine)
- local whitespaces = ""
- init()
- if not textColor then
- textColor = color.white
- end
- if not highlightColor then
- highlightColor = colors.black
- end
- if isAdvanced then
- term.setTextColor(textColor)
- term.setBackgroundColor(highlightColor)
- end
- if doFillLine then
- while true do
- posOfNewline = message:find("\n")
- if doBreak then
- break
- end
- if posOfNewline == nil then
- posOfNewline = message:len() + 1
- doBreak = true
- end
- for i = 1, term.getSize() - message:sub(1, posOfNewline - 1):len()
- % term.getSize() do
- whitespaces = whitespaces.." "
- end
- message = message:sub(1, posOfNewline - 1)..whitespaces..
- message:sub(posOfNewline + 1, message:len())
- end
- end
- write(message..whitespaces)
- if isAdvanced then
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.black)
- end
- end
- function colorPrint(message, color)
- colorWrite(message.."\n", color)
- end
- function highlightPrint(message, color, doFillLine)
- highlightWrite(message.."\n", color, doFillLine)
- end
- function colorPrintWithHighlight(message, textColor, highlightColor, doFillLine)
- colorWriteWithHighlight(message.."\n", textColor, highlightColor, doFillLine)
- end
Advertisement
Add Comment
Please, Sign In to add comment