textutils.slowprint("welcome")
printer = peripheral.wrap("right")
printer.newPage()
print("type exit() to print")
while true do
local input = io.read()
if input == exit() then
printer.endPage()
break
else
repeat
printer.write()
until string.find(input, "exit()")
end
end
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Need help with making a program
Started by Roadhouse699, 08 March 2013 - 02:52 AMPosted 08 March 2013 - 03:52 AM
In the past, I've mastered a program that repeats the words "you didn't say the magic word", a password door, a calculator, and a ICBM missile launcher. But this program has had me stuck since before I made some of the other programs: a notebook. I'm trying to make it so that you can keep typing a document until you type "exit()", and then it will print the document and close the program, but it prints the page as soon as I start the program. Here's the code I'm using:
Posted 08 March 2013 - 04:18 AM
You could use:
:)/>
Also use peripheral.wrap("right") instead peripheral.wrap(right)
Edit derp:
...
until string.find(input, "exit()")
:)/>
Also use peripheral.wrap("right") instead peripheral.wrap(right)
Edit derp:
textutils.slowprint("welcome")
printer = peripheral.wrap("right")
printer.newPage()
print("type exit() to print")
while true do
local input = io.read()
if input == "end()" then
printer.endPage()
break
else
printer.write(input) -- not sure about the printer API
end
sleep(0)
end
Edited on 08 March 2013 - 07:32 AM
Posted 08 March 2013 - 07:55 AM
Thanks, I'll try this out.
Posted 08 March 2013 - 08:08 AM
I tried this, and after I typed the first line, the computer blanked out for a few seconds and then this problem came back:
12:too long with out yielding.
12:too long with out yielding.
Posted 08 March 2013 - 08:11 AM
Change
local input = io.read
to local input = io.read()
Posted 08 March 2013 - 08:16 AM
Already did. I'll update the code in the original post
Posted 08 March 2013 - 08:31 AM
Derped on that, was like its now 15:30, you have to cycle 45 minutes and 16:00 you have to get there xDChangetolocal input = io.read
local input = io.read()
Edited my post
Try my code now, hopefully it works this time :P/>
Posted 08 March 2013 - 11:35 AM
IT WORKED!!!!!!!!!!!!!!! thank you!!!
I've been trying to crack this for like a month! Thanks to all you've told me, I'm so much better at programming now!
I've been trying to crack this for like a month! Thanks to all you've told me, I'm so much better at programming now!