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

1.33, SSP/SMP - monitors VS. print()

Started by darkhog, 29 May 2012 - 06:40 PM
darkhog #1
Posted 29 May 2012 - 08:40 PM
Here is code I'm using:
monitor = peripheral.wrap("right")
term.redirect(monitor)
kate=
[[ .###.|
## oo##|
'#___#'|
'###' |
  KATE |]]
term.clear()
term.setCursorPos(1,1)
print(kate)
term.restore()
Nothing wrong, huh? (aside of explicitly assuming monitor is on right?) Wrong! Single monitor (1x1x1 block) has resolution 7x5 characters (widthXheight). So I made nice, 5 characters in height ascii art that should be displayed then. Unfortunately, no matter what I do, it prints only last 4 lines. Same if I use normal string (in quotes) with new line, n escapecodes.

I'd use term.write, but it doesn't honor n or multiline strings written using [[]] (when string is written that way, it display questionmark where new line is supposed to be…)

//edit for qabove code to work properly, your monitor has to be placed on right side of computer and be at least two blocks wide. It was made for scrolling news system, similar to those you sometimes see on train stations or places like that.
MysticT #2
Posted 29 May 2012 - 08:48 PM
The problem is that the print function adds a newline at the end of the string, wich adds a blank line after your text. Try using write instead, it should work.
darkhog #3
Posted 29 May 2012 - 08:53 PM
As I said, write doesn't honor newlines or n. Which makes it useless for printing asciiart in one go.

//edit: O.o… write() itself works. But why the heck term.write() uses it's own method which doesn't honor newlines instead of being just a wrapper to write()?
MysticT #4
Posted 29 May 2012 - 08:56 PM
No, you said term.write(), wich doesn't support newlines. I mean write(), wich does support newlines. print actually uses write, but adds a write("n") after your text.

monitor = peripheral.wrap("right")
term.redirect(monitor)
kate=
[[ .###.|
## oo##|
'#___#'|
'###' |
  KATE |]]
term.clear()
term.setCursorPos(1,1)
write(kate)
term.restore()
PixelToast #5
Posted 30 May 2012 - 01:05 AM
i was having trouble displaying ascii art too, thanks