Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local version = "1.4.2"
- local textColor = colors.white
- local resetCurs = function()
- term.setCursorPos(1, 1)
- end
- local set = function()
- term.setTextColor(textColor)
- end
- --Returns version of API
- getVersion = function()
- return version
- end
- getTextColor = function()
- return textColor
- end
- setTextColor = function(textcolor)
- textColor = textcolor
- end
- --Gets the string length and subtracts it to get
- --cursor position for text to be centered
- centeredText = function( y, str )
- set()
- local w, h = term.getSize()
- term.setCursorPos( math.floor( w - #str) / 2, y )
- term.write( str )
- --resetCurs()
- end
- --Gets color and cords to draw a rectangle
- coloredBox = function( color, sx, sy, ex, ey )
- set()
- term.setBackgroundColor(color)
- for i = sx, ex do
- for k = sy, ey do
- term.setCursorPos( i, k )
- term.write(" ")
- end
- end
- resetCurs()
- end
- --Line on the X axes
- coloredHorzLine = function( color, sx, ex, y)
- set()
- term.setBackgroundColor(color)
- for i = sx, ex do
- term.setCursorPos( i, y)
- term.write(" ")
- end
- resetCurs()
- end
- --Sets a colored rectangle in the full terminal
- setBackground = function( color )
- local w, h = term.getSize()
- coloredBox(color, 1, 1, w, h)
- resetCurs()
- end
- --Draws with a background color
- drawString = function( str, color, x, y )
- set()
- term.setTextColor(colors.white)
- term.setBackgroundColor(color)
- term.setCursorPos(x, y)
- term.write(str)
- resetCurs()
- end
- --Given bounds and ran in a statement then it will return
- getClickInBounds = function( sx, sy, ex, ey )
- set()
- event, button, x, y = os.pullEvent("mouse_click")
- if x <= ex and x >= sx and y <= ey and y >= sy then
- return true
- else
- return false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement