This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
WattDev's profile picture

This is how to create a new line after using term.write("")

Started by WattDev, 17 April 2017 - 06:40 AM
WattDev #1
Posted 17 April 2017 - 08:40 AM
Have you guys wondering how to create a new line after using these code like term.write to tell something to user??


These are the basic function for program/api to make a new line


function newLine()
  xPos, yPos = term.getCursorPos()
  term.setCursorPos(1,(yPos + 1))
end

Easy huh?
TheRockettek #2
Posted 17 April 2017 - 10:15 AM
you can always use print(). It has text wrapping and makes a new line after calling.
H4X0RZ #3
Posted 17 April 2017 - 12:25 PM
Or just use print instead of term.write?
Waitdev_ #4
Posted 17 April 2017 - 12:58 PM
Or just use \n in the string at the end?
Exerro #5
Posted 17 April 2017 - 01:11 PM
term.write doesn't handle newlines. It's only print/write that do because they word wrap.

Anyway, yeah, print"", and write"\n" both do the exact same thing as the whole 4 line function.
Lyqyd #6
Posted 17 April 2017 - 04:17 PM
It's not just that you can use write or print to more easily move to a new line, this also doesn't scroll the screen if you're already on the bottom row.
Bomb Bloke #7
Posted 17 April 2017 - 11:32 PM
Sort of worth noting that term.redirect() can be used to get access print/write through displays other than the default. External monitors, for eg.