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

Printer Input help

Started by sflynn, 27 February 2014 - 09:13 PM
sflynn #1
Posted 27 February 2014 - 10:13 PM
Ok, so I was trying to make a program where you just type what you want then it prints on "printer_0". basically a text editor that print when you have typed print or somthing and i am stumped.
what I have so far:
print = peripheral.wrap("printer_0")
print.getPaperLevel()
print.getInkLevel()
sleep(2)
input = io.read() – now I have no clue what to do
ClassicRockFan #2
Posted 28 February 2014 - 01:59 AM
Instead of the io.read do something like this

Print(enter desired text:)
Input = read
Printer.write(input)

Of course add "" where necessary
theoriginalbit #3
Posted 28 February 2014 - 02:12 AM
-snip-
This task may be slightly ahead of you, I suggest that you maybe start off with something smaller, the task you're trying to accomplish will take much more than 5 lines of code, the `rom/programs/edit` program is 100s of lines of code. However if you do wish to continue this we will help you when you get stuck, but we will always need more information about what is happening what you want to happen and/or any error messages that occur as well. But you definitely do need to think about what you want this program to do a lot more than you have, you need to think about what you want to happen given certain circumstances with the printer failing to print, and how you program will look at work. Like I said I suggest that you start off with something smaller however if you do insist on continuing I think taking a look at the `rom/programs/edit` program for inspiration will be beneficial.

Instead of the io.read do something like this

Print(enter desired text:)
Input = read
Printer.write(input)

Of course add "" where necessary
Not only is this suggestion a pointless change to the OPs code that doesn't achieve what the OP wants, but every line of code you've wrote is wrong and the program would not run. I suggest learning a lot more Lua and ComputerCraft before providing anymore assistance in Ask a Pro.
ClassicRockFan #4
Posted 28 February 2014 - 02:15 AM
That program would work perfectly fine. It wouldn't add any extra pages left or ink left. But it does take the user input text, and print it on paper.
theoriginalbit #5
Posted 28 February 2014 - 02:20 AM
That program would work perfectly fine. It wouldn't add any extra pages left or ink left. But it does take the user input text, and print it on paper.
definitely not!

here is your code

Print(enter desired text:)
Input = read
Printer.write(input)

here is a working version of your code

print("enter desired text: ")
local input = read()
peripheral.call("printer_0", "write", input)

note all the differences. every line of your program had a problem, each problem was a lack of basic Lua skills, and one problem with not knowing how ComputerCraft works. As I previously stated you need to learn a lot more Lua before being able to adequately assist in Ask a Pro.
ClassicRockFan #6
Posted 28 February 2014 - 02:29 AM
Sorry OP about ruining your thread. Check your msgs originalbit
sflynn #7
Posted 05 March 2014 - 10:28 PM
ok sorry was on a trip but thank you I will try everything and just for the count I knew that 5 lines would not work as I have written an operating system that was 100+ lines.