17 posts
Posted 08 March 2013 - 12:23 PM
Hello, I was wondering if there was a command to print the text currently on the screen. Like say I send a message via rednet to another computer is there a way I can print the message out? Thank you for your time and help in advance. Here's the code I got that I want to add to if it's possible.
rednet.open = ("top")
id, message = rednet.receive ()
print ("Computer".. id .."has sent us a message!")
print ("The message is...")
sleep (2)
term.clear ()
term.setCursorPos (1, 1)
print (message)
1511 posts
Location
Pennsylvania
Posted 08 March 2013 - 12:36 PM
print("the message is "..massage) should work nicely. Any variables can be printed like this
Lol i typed "massage" :P/>
17 posts
Posted 08 March 2013 - 12:39 PM
print("the message is "..massage) should work nicely. Any variables can be printed like this
Sorry, I don't think I explained myself correctly is there a way to print it to an attached printer? instead of to the computer. I'm talking like physical (in a digital world anyway) paper with ink on it.
1511 posts
Location
Pennsylvania
Posted 08 March 2013 - 12:41 PM
Well i would go to the wiki and look at the printer api. Im on my phone so i cannot link you there.
17 posts
Posted 08 March 2013 - 12:54 PM
Okay, thank you.
2151 posts
Location
Auckland, New Zealand
Posted 08 March 2013 - 12:56 PM
Now, I haven't tested this and you'll want to add crash prevention, but basically:
printer = peripheral.wrap("left") -- wrap the printer
printer.write(message)
Take a look at the
Printer (API)
17 posts
Posted 08 March 2013 - 01:04 PM
Now, I haven't tested this and you'll want to add crash prevention, but basically:
printer = peripheral.wrap("left") -- wrap the printer
printer.write(message)
Take a look at the
Printer (API)
cool, thank you. I'll do some testing with thisDid some testing. You need to start the printer with
printer.peripheral.wrap ("left")
printer.newPage () -- loads the paper to be written
printer.write (message) -- does the actual printing
printer.endPage () -- outputs page to the tray.
Eventually I came up with the code
rednet.open ("top")
printer.peripheral.wrap ("left")
id, message - rednet.receive ()
print ("Computer".. id .."has sent us a message!")
print ("The message is...")
sleep (2)
term.clear ()
term.setCursorPos (1, 1)
print (message)
printer.newPage ()
printer.write (message)
printer.endPage ()
sleep(0)
You can also set this up so it will continuously print any message going through your section of rednet. I imagine you could use sets of computers and modems sending messages to each other and monitor a large area. But, currently the code I pasted is more of an "email" type system where you can keep the documents.
Edit: Ran in to another issue. It will only print one line of text to the paper. I'll be messing around with this for a couple of hours at least and I got school tomorrow so I'll get back to this thread then.
2151 posts
Location
Auckland, New Zealand
Posted 08 March 2013 - 01:36 PM
–snip snip–
Edit: Ran in to another issue. It will only print one line of text to the paper. I'll be messing around with this for a couple of hours at least and I got school tomorrow so I'll get back to this thread then.
The reason it is only printing one line per-page is because you're calling these every time. Only run that when needed.
printer.newPage () -- loads the paper to be written
printer.endPage () -- outputs page to the tray.