42 posts
Location
New Zealand
Posted 08 July 2013 - 12:24 AM
I feel silly now, don't I? How do I print out each string from a table on a new line? For example, I would like to print this table
stuff = {
"Option1",
"Option2",
"Option3"
}
like this in a gui:
Option1
Option2
Option3
I have the gui, I just don't know how to print it out.
1688 posts
Location
'MURICA
Posted 08 July 2013 - 01:01 AM
Loop through and print each one with term.write(). print() and write() would also work semi-well for your purposes, except print() adds a new line, and write() wordwraps text, which could screw up some things in the future. Therefore, it's generally safer using term.write() when making GUIs.
You could make a function that takes an offset, then adds to the specific coordinates of each printed option. Doing "printMenu(5,5)" would print every option at position 5,5.
function printMenu(menu, x, y)
for i=1, #menu do
term.setCursorPos(x, y + i - 1)
term.write(menu[i])
end
end
42 posts
Location
New Zealand
Posted 08 July 2013 - 01:04 AM
Loop through and print each one with term.write(). print() and write() would also work semi-well for your purposes, except print() adds a new line, and write() wordwraps text, which could screw up some things in the future. Therefore, it's generally safer using term.write() when making GUIs.
You could make a function that takes an offset, then adds to the specific coordinates of each printed option. Doing "printMenu(5,5)" would print every option at position 5,5.
function printMenu(menu, x, y)
for i=1, #menu do
term.setCursorPos(x, y + i - 1)
term.write(menu[i])
end
end
I assume menu is where you enter the name of the table?
1688 posts
Location
'MURICA
Posted 08 July 2013 - 01:13 AM
You assume correctly.