11 posts
Posted 08 May 2013 - 11:30 AM
Showing a List on a Monitor
I feel like a nub for asking cause I've did it before but….
How do i get a monitor to show a list. I can get words to show on the monitor but i cant get it to show a list. Below is somewhat how I'd like for it to look.
To-Do List
1. Blah
2. Blah
3. Blah
If possible I'd like the "To-Do List" centered, bold, and a blue color. The "1. Blah" I'd like to be red. Thanks in advance.
8543 posts
Posted 08 May 2013 - 12:45 PM
Split into new topic.
379 posts
Location
Hawaii
Posted 08 May 2013 - 02:25 PM
Print in the center: (screen width - text length) / 2 + 1, where text length in this case would be 10 ("To-Do List")
Printing a certain color: Use the colors API.
http://www.computerc...nfo/wiki/Colors And use term.setTextColor(color) to set it. Example: term.setTextColor(colors.blue)
Printing a list: You could save the list to a file, in plaintext. Then, read the file and print it to the screen. For this, perhaps a raw file would be easier.
See
http://www.computerc...fo/wiki/Fs.open for file writing/reading. You'll want to look for modes "w" (write) and "r" (read), and possibly "a" (append).
52 posts
Posted 08 May 2013 - 04:26 PM
Try this:
endnum= --Put the end number of the list here
messagetext="" --The string going into the list goes here
for i=1,endnum,1 do
print(i .. ". " .. messagetext)
end
1583 posts
Location
Germany
Posted 08 May 2013 - 05:42 PM
x,y = term.getSize()
local toDo = {"bla","blaaa"}
term.setTextColor(colors.blue)
term.setCursorPos((x-string.len("To-Do-List"))/2+1,1)
term.write("To-Do-List")
term.setTextColor(colors.red)
term.setCursorPos(1,3)
for k,v in pairs(toDo) do
print(k..". "..ToDo[k])
end
I think that works :]
1688 posts
Location
'MURICA
Posted 08 May 2013 - 10:16 PM
local monitorSide = "top" -- replace this with the side your monitor is on
local title = "To-Do List"
local list = { -- replace these with your todo list
'Do something',
'Do something else',
'Etc.'
}
local mon = peripheral.wrap(monitorSide)
local w,h = mon.getSize()
mon.setBackgroundColor(colors.white)
mon.clear()
mon.setCursorPos((w - #title) / 2, 2)
mon.setTextColor(colors.red)
mon.write(title)
mon.setTextColor(colors.blue)
for i=1, #list do
mon.setCursorPos(3, 3 + i)
mon.write(i..'. '..list[i])
end
I felt like being fancy on this one. White background because blue and red don't show up well on black.
11 posts
Posted 08 May 2013 - 11:55 PM
Thanks for the help. Kingdaro I tried the program and its saying
bios:338: [string 'list']:6: '}' expected (to close '{' at line 4)
I typed it exactly like you did. Also just fyi, this is for a 2x2 adv monitor.
7508 posts
Location
Australia
Posted 09 May 2013 - 12:04 AM
Thanks for the help. Kingdaro I tried the program and its saying
bios:338: [string 'list']:6: '}' expected (to close '{' at line 4)
I typed it exactly like you did.
I have a feeling that you either missed the closing } for the table OR you have a period/full-stop or forgot the comma at the end of one of your entries in the table