Posted 10 February 2013 - 01:56 AM
So I made this for my new ComputerCraft YouTube program and thought I may as well post it here as it's quite handy, imo.
The functions can be found here
Usage Example (confirmBox and drawBox functions):
How it works:
The height of the box is determined by how many strings you give it.
Usage Example (textBox function):
(This box allows as much text as you need - supports scroll!)
How it works:
The functions can be found here
Usage Example (confirmBox and drawBox functions):
How it works:
borderCol = colour of the outside border
boxCol = colour of the inside of the box
headingCol = colour of the heading that appears at the top of the box
textCol = colour of the text that appears within the box
xStart = starting X position of the box (top left hand corner of the box)
xEnd = ending X position of the box (top right hand corner of the box)
yStart = starting Y positon of the box (top line)
... = arguments, accepts as many as you want. First one is the title.
The height of the box is determined by how many strings you give it.
Spoiler
os.loadAPI("box")
screenX, screenY = term.getSize()
-- Draw a confirm box
term.clear()
opt = box.confirmBox(colours.grey, colours.lightGrey, colours.red, colours.white, 5, screenX - 5, 6, "Confirm", "Are you sure you want to", "delete the file?", "thisFile")
term.clear()
term.setCursorPos(1, 1)
print(opt)
if opt == "YES" then
-- Yes let's delete the file
else
-- Why not?
end
sleep(1)
-- Draw a normal box with text
term.clear()
box.drawBox(colours.grey, colours.lightGrey, colours.red, colours.white, 5, screenX - 5, 6, "", "This is a test and can be", "considered as the most useless", "information. But it's just a test!") -- Use "" as the first string if you don't want it to have a heading
Usage Example (textBox function):
(This box allows as much text as you need - supports scroll!)
How it works:
--[[
boxCol = colour of the entire box
textCol = colour of the text inside of the box area
xStart = starting X position of the box
xEnd = ending X position of the box
yStart = starting Y position of the box
yEnd = ending Y position of the box
tText = Can be a string OR a table
String:
- Use '\n' to separate lines.
Table:
- Make sure lines are WELL spaced for the area
of the box or else it will fail!
--]]
Spoiler
msg = "New update!\n\nWhat's new:\n - Feature 1\n - Feature 2\n - Feature 3\n - Feature 4\n - Feature 5\n\nDownload:\nwww.pastebin/code\n\n\nFeedback and suggestions are welcome!"
tab = {
"New update!",
"",
"What's new:",
" - Feature 1",
" - Feature 2",
" - Feature 3",
" - Feature 4",
" - Feature 5",
"Download:",
"www.pastebin/code",
"", "",
"Feedback and suggestions are welcome!"
}
screenX, screenY = term.getSize()
os.loadAPI("box")
term.setBackgroundColour(colours.black)
term.clear()
term.setCursorPos(1, 1)
box.textBox(colours.lightGrey, colours.red, 2, screenX - 2, 3, 10, msg) -- or use tab for the table