Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local w,h = term.getSize()
- function drawSquare( borderCol, boxCol, textCol, xStart, xEnd, yStart, ... )
- --[[ Defines the max amount of characters that can be printed within
- the box. If exceeded, it will error.
- --]]
- local maxLength = xEnd - xStart - 2
- --[[ This part does the border of the box ]]--
- term.setBackgroundColour(borderCol)
- for x = xStart, xEnd do
- term.setCursorPos(x, yStart)
- write(" ")
- term.setCursorPos(x, yStart+#arg+2)
- write(" ")
- end
- for y = yStart + 1, yStart + #arg + 1 do
- term.setCursorPos(xStart, y)
- write(" ")
- term.setCursorPos(xEnd, y)
- write(" ")
- end
- --[[ This writes the title, which is the first string within
- the '...'
- --]]
- term.setTextColour(textCol)
- term.setCursorPos((xEnd - xStart - #arg[1])/2 + xStart + 1, yStart)
- write(arg[1])
- --[[ This part fills the insides of the box with the desired
- colour
- --]]
- term.setBackgroundColour(boxCol)
- for x = xStart + 1, xEnd - 1 do
- for y = yStart + 1, yStart + #arg + 1 do
- term.setCursorPos(x, y)
- write(" ")
- end
- end
- --[[ arg is '...' and accepts as many as you want, but of course - having
- more than 16? would be silly.
- It centeres each text within the box
- --]]
- for i = 2, #arg do
- if #arg[i] > maxLength then error("Length of arg #" .. i .. " exceeds max limit of " .. maxLength .. " characters.") end
- term.setCursorPos((xEnd - xStart - #arg[i])/2 + xStart + 1, yStart + i)
- write(arg[i])
- end
- --[[ Resets the variables and sets the cursorpos to be after the box. --]]
- term.setBackgroundColour(colours.black)
- term.setTextColour(colours.white)
- term.setCursorPos(1, yStart + #arg + 4)
- end
- function printCentered(y, s)
- local x = math.floor((w - string.len(s)/2)
- term.setCursorPos(x, y)
- term.clearLine()
- term.write(s)
- end
- local function drawMenu()
- term.clear()
- drawSquare(colours.lime, colours.lightBlue, colours.red, 10,30,2, "Warning", "It works!", "lssssssssssssstol", "Line 3", "Line 4")
- end
- drawMenu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement