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

printer issues

Started by jewelshisen, 21 December 2012 - 10:28 AM
jewelshisen #1
Posted 21 December 2012 - 11:28 AM
I have a program that is supposed to print out two lines of text. However when I run the program it always tries to print a single line. How can i seperate them?
AndreWalia #2
Posted 21 December 2012 - 11:30 AM

print("This is my first line!")
print("This is my second line!")

Ignore everything I just said
NDFJay #3
Posted 21 December 2012 - 11:31 AM

plain text:
print("this is line 1 \n this is line 2")

defined functions
print(line1.."\n"..line2)

the \n tells the print function to print on the next line
jewelshisen #4
Posted 21 December 2012 - 11:54 AM

plain text:
print("this is line 1 \n this is line 2")

defined functions
print(line1.."\n"..line2)

the \n tells the print function to print on the next line

Oh. I was trying to use two seperate print functions! So i just need to compile them into one print function?
NDFJay #5
Posted 21 December 2012 - 11:55 AM

plain text:
print("this is line 1 \n this is line 2")

defined functions
print(line1.."\n"..line2)

the \n tells the print function to print on the next line

Oh. I was trying to use two seperate print functions! So i just need to compile them into one print function?

what are you trying to print? it should work with 2 seperate print functions to print on seperate lines but compiling then into 1 makes the code cleaner, both ways should work

post your code if it still doesnt work
NDFJay #6
Posted 21 December 2012 - 12:12 PM

plain text:
print("this is line 1 \n this is line 2")

defined functions
print(line1.."\n"..line2)

the \n tells the print function to print on the next line

Oh. I was trying to use two seperate print functions! So i just need to compile them into one print function?


forget everything I said… try this


n = peripheral.wrap("left") --n is the printer
n.newPage()
n.write("Text for line 1 here")
n.setCursorPos(1,2)
n.write("Tesxt for line 2 here")
n.endPage()
theoriginalbit #7
Posted 21 December 2012 - 01:14 PM
Also please note that this is the wrong section to post this. Please request this to be moved to the "Ask a Pro" section. Click "report" on any reply or the OP and type in the box the request to move to the correct section :)/> and if you ever need any help again post it directly to the "Ask a pro" section.

Also it is good practise to include the code that you have currently got so that we can take a look at it and suggest fixes to you :)/>
jewelshisen #8
Posted 21 December 2012 - 01:15 PM

plain text:
print("this is line 1 \n this is line 2")

defined functions
print(line1.."\n"..line2)

the \n tells the print function to print on the next line

Oh. I was trying to use two seperate print functions! So i just need to compile them into one print function?


forget everything I said… try this


n = peripheral.wrap("left") --n is the printer
n.newPage()
n.write("Text for line 1 here")
n.setCursorPos(1,2)
n.write("Tesxt for line 2 here")
n.endPage()

YES! It fixed it! See everytime i tried to use \n to make a new line it just returned a ? and kept on the same line!
NDFJay #9
Posted 21 December 2012 - 01:27 PM

plain text:
print("this is line 1 \n this is line 2")

defined functions
print(line1.."\n"..line2)

the \n tells the print function to print on the next line

Oh. I was trying to use two seperate print functions! So i just need to compile them into one print function?


forget everything I said… try this


n = peripheral.wrap("left") --n is the printer
n.newPage()
n.write("Text for line 1 here")
n.setCursorPos(1,2)
n.write("Tesxt for line 2 here")
n.endPage()

YES! It fixed it! See everytime i tried to use \n to make a new line it just returned a ? and kept on the same line!

its a bit odd, the wiki says it works the same as the term and mon API's but apparently not, theres probably something we're missing but either way it works now ^_^/>
Orwell #10
Posted 21 December 2012 - 01:36 PM
term.write also ignores '\n'. Support for '\n' is implemented in the write and print functions from bios.lua . You can easily take those 2 functions and adjust it to support monitors and/or printers.

Also, I don't see this mentioned earlier so I'll say it. This post is in the wrong section. Programs is reserved for actual published programs, it just makes finding stuff easier. :)/>
NDFJay #11
Posted 21 December 2012 - 01:44 PM
term.write also ignores '\n'. Support for '\n' is implemented in the write and print functions from bios.lua . You can easily take those 2 functions and adjust it to support monitors and/or printers.

Also, I don't see this mentioned earlier so I'll say it. This post is in the wrong section. Programs is reserved for actual published programs, it just makes finding stuff easier. :)/>

Thats actually a good point, I've spent so much time in the "Ask A Pro" section lately I didnt even notice it was in the wrong place lol I think I need sleep, my brains not functioning right… maybe after one more line of code
theoriginalbit #12
Posted 21 December 2012 - 01:46 PM
Also, I don't see this mentioned earlier so I'll say it. This post is in the wrong section. Programs is reserved for actual published programs, it just makes finding stuff easier. :)/>

I mentioned it :P/>
Orwell #13
Posted 21 December 2012 - 01:56 PM
Also, I don't see this mentioned earlier so I'll say it. This post is in the wrong section. Programs is reserved for actual published programs, it just makes finding stuff easier. :)/>

I mentioned it :P/>
Oh yes, you mentioned it quite lengthy. :)/> Didn't notice that earlier. <_</>