Monitor text, make new lines?
#1
Posted 15 July 2012 - 05:50 PM
All I can use for text is mon.write("") and I cant figure out how to make the text go to a new line. Keep in mind, this is a function in an ongoing program, not monitor right blah.
Can anyone help me?
#2
Posted 15 July 2012 - 05:57 PM
#3
Posted 15 July 2012 - 06:03 PM
mon.write ("Rule 1: n")
It shows a question mark. And when I have it outside of quotations, it throws an error.
#4
Posted 15 July 2012 - 06:14 PM
Tusillody, on 15 July 2012 - 06:03 PM, said:
mon.write ("Rule 1: n")
It shows a question mark. And when I have it outside of quotations, it throws an error.
Edit: dammit I was wrong again /> keep on getting the / and mixed up
#5
Posted 15 July 2012 - 06:17 PM
And /n outside, gives an error for trying to use arithmetic on a string.
And Because i have over 10 lines of rules, i was trying to make it seem a bit neater. But If nothing else works, Ill just try that />
#6
Posted 15 July 2012 - 07:14 PM
local mon = peripheral.wrap("<side>") -- I guess you already know this term.redirect(mon) -- redirect the output to the monitor print("Hello World!!") -- use print, write, and any function that uses the terminal, it will show in the minitor term.restore() -- after printing everything, restore the output to the terminal
BTW, this is how the monitor program works.
#7
Posted 15 July 2012 - 07:26 PM
MysticT, on 15 July 2012 - 07:14 PM, said:
local mon = peripheral.wrap("<side>") -- I guess you already know this term.redirect(mon) -- redirect the output to the monitor print("Hello World!!") -- use print, write, and any function that uses the terminal, it will show in the minitor term.restore() -- after printing everything, restore the output to the terminal
BTW, this is how the monitor program works.
Awesome! This will work perfect, thank you!
#8
Posted 15 July 2012 - 07:43 PM
so for example, you would have
local mon = peripheral.wrap("<side>") -- I guess you already know this
term.redirect(mon) -- redirect the output to the monitor
print("Hello World!!") -- use print, write, and any function that uses the terminal, it will show in the minitor
term.restore() -- after printing everything, restore the output to the terminal
as MysticT said, But if you want to make another line for rules example it would be like this:
local mon = peripheral.wrap("<side>")
term.redirect(mon)
mon.setCursorPos(1,1)
print("Rules:")
mon.setCursorPos(1,2) -- this sets it to the second line
print("1: No Griefing!")
term.restore()
and so forth, it should work, it's how I did it with mine. Goodluck!!
#9
Posted 15 July 2012 - 07:47 PM
bloodless2010, on 15 July 2012 - 07:43 PM, said:
so for example, you would have
local mon = peripheral.wrap("<side>") -- I guess you already know this
term.redirect(mon) -- redirect the output to the monitor
print("Hello World!!") -- use print, write, and any function that uses the terminal, it will show in the minitor
term.restore() -- after printing everything, restore the output to the terminal
as MysticT said, But if you want to make another line for rules example it would be like this:
local mon = peripheral.wrap("<side>")
term.redirect(mon)
mon.setCursorPos(1,1)
print("Rules:")
mon.setCursorPos(1,2) -- this sets it to the second line
print("1: No Griefing!")
term.restore()
and so forth, it should work, it's how I did it with mine. Goodluck!!
And why don't you just do:
local mon = peripheral.wrap("<side>") term.redirect(mon) print("Rules:") print("1: No Griefing!") -- All the prints you want here term.restore()It would have the same effect, since print already moves the cursor to the next line.
#10
Posted 15 July 2012 - 07:49 PM
MysticT, on 15 July 2012 - 07:47 PM, said:
bloodless2010, on 15 July 2012 - 07:43 PM, said:
so for example, you would have
local mon = peripheral.wrap("<side>") -- I guess you already know this
term.redirect(mon) -- redirect the output to the monitor
print("Hello World!!") -- use print, write, and any function that uses the terminal, it will show in the minitor
term.restore() -- after printing everything, restore the output to the terminal
as MysticT said, But if you want to make another line for rules example it would be like this:
local mon = peripheral.wrap("<side>")
term.redirect(mon)
mon.setCursorPos(1,1)
print("Rules:")
mon.setCursorPos(1,2) -- this sets it to the second line
print("1: No Griefing!")
term.restore()
and so forth, it should work, it's how I did it with mine. Goodluck!!
And why don't you just do:
local mon = peripheral.wrap("<side>") term.redirect(mon) print("Rules:") print("1: No Griefing!") -- All the prints you want here term.restore()It would have the same effect, since print already moves the cursor to the next line.
#11
Posted 19 September 2012 - 05:57 PM
local function redirector(side) term.redrect(peripheral.wrap(side)) local temp={} for k,v in pairs(term) do temp[k]=v end term.restore() return temp end
and that will return a table of functions including the print one
#12
Posted 19 September 2012 - 06:15 PM
#13
Posted 19 September 2012 - 06:16 PM
the print function isn't magic, though. You could implement your own easily enough...
function printTo(device,text) local lines={} --break into lines on ns --we add a n at the end, so it behaves like print and so the match can find the last line string.gsub(text.."n","(.-)n",function(v) lines[#lines+1]=v end) local _,row=device.getCursorPos() local _,height=device.getSize() for i=1,#lines do --write the line device.write(lines[i]) --move to next row row=row+1 --if this went off the screen, scroll if row>height then row=height device.scroll(1) end --set to start of next line device.setCursorPos(1,row) end end
:edit2: note that this doesn't support tabs (t).
#14
Posted 19 September 2012 - 06:24 PM
#15
Posted 20 October 2012 - 03:14 AM
x = 1
y = 1
function setPoint()
mon.setCursorPos(x,y)
end
setPoint()
mon.write"Hello, User!"
y = y+1
setPoint()
mon.write"This is the Next line!"
#16
Posted 20 October 2012 - 03:46 AM
mon.write [[ Rules --------- 1. Follow rule #2 2. Follow rule #3 3. Follow rule #1 ]]
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users