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?
 
        I believe it's /n. Also why don't you use mon.setCursorPos?I thought it would, but when I have
mon.write ("Rule 1: n")
It shows a question mark. And when I have it outside of quotations, it throws an error.
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
The easier way would be to redirect the terminal output and then use print: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.
If you want to make a new line, you could also use setCursorPos,
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!!
local mon = peripheral.wrap("<side>")
term.redirect(mon)
print("Rules:")
print("1: No Griefing!")
-- All the prints you want here
term.restore()
Oh ok, I'm new to this I didn't know! Thanks! :P/>/>If you want to make a new line, you could also use setCursorPos,
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:It would have the same effect, since print already moves the cursor to the next line.local mon = peripheral.wrap("<side>") term.redirect(mon) print("Rules:") print("1: No Griefing!") -- All the prints you want here term.restore()
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
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
mon.write [[
Rules
---------
1. Follow rule #2
2. Follow rule #3
3. Follow rule #1
]]