This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
[Lua][Question] Printing Programs
Started by JasonAHawkins, 20 November 2012 - 05:48 AMPosted 20 November 2012 - 06:48 AM
Is it possible to make program "1" print the text in program "2" onto a piece of paper using a printer?
Posted 20 November 2012 - 08:04 AM
Yes, you should open program2 as a file, read it and print it :(/>/> (ask for code if needed )
Posted 20 November 2012 - 11:35 AM
Thanks,and wow this looks complicated. I am kinda a noob to Lua.
Posted 20 November 2012 - 11:41 AM
Nice :(/>/> Just wanted to say that the tC table is redundant. It's exactly the same as the colours API (except for the methods of course). You could just do colors['blue']. Not a big deal, just wanted to share this. :)/>/>Made a program that should work: Pastebin :(/>/>
Posted 20 November 2012 - 11:58 AM
Is there any simpler code for this because i would like to understand what i am writing.
Posted 20 November 2012 - 12:07 PM
Is this easier for you to understand? If not, you might want to start out with something easier. :(/>/> Or ask lots of questions here. That's what we're here for. :(/>/>
I basically cut out all the color thingies. printError() is a built-in function that prints in red. :)/>/>
http://pastebin.com/LWCJfR9X
I basically cut out all the color thingies. printError() is a built-in function that prints in red. :)/>/>
http://pastebin.com/LWCJfR9X
Posted 21 November 2012 - 01:59 AM
Nice :(/>/> Just wanted to say that the tC table is redundant. It's exactly the same as the colours API (except for the methods of course). You could just do colors['blue']. Not a big deal, just wanted to share this. :)/>/>
Would this work?
function pC(col, text)
term.setTextColour(colours[col])
print(text)
end
pC("red", "Will this text be red?")
If it does, I wasted so much time typing those numbers in :(/>/>
Posted 21 November 2012 - 02:19 AM
Yes, that would work. :)/>/> Sorry… :(/>/>Nice :)/>/> Just wanted to say that the tC table is redundant. It's exactly the same as the colours API (except for the methods of course). You could just do colors['blue']. Not a big deal, just wanted to share this. :)/>/>
Would this work?function pC(col, text) term.setTextColour(colours[col]) print(text) end pC("red", "Will this text be red?")
If it does, I wasted so much time typing those numbers in :(/>/>
Posted 21 November 2012 - 02:32 AM
Yes, that would work. :)/>/> Sorry… :)/>/>Nice :)/>/> Just wanted to say that the tC table is redundant. It's exactly the same as the colours API (except for the methods of course). You could just do colors['blue']. Not a big deal, just wanted to share this. :)/>/>
Would this work?function pC(col, text) term.setTextColour(colours[col]) print(text) end pC("red", "Will this text be red?")
If it does, I wasted so much time typing those numbers in :(/>/>
I could have sworn I tried that though and it kept giving me the error: "number expected" hmm, might have done colours.[col] :(/>/>. Oh well, thanks for telling me so I don't waste timed next time :)/>/>
To OP: Do you want me to explain the code for you?
Posted 21 November 2012 - 09:18 AM
No it's simple. Really. Basically to do it fast you only need about 8 lines :(/>/> all the rest of the codes that are here is only optional but recommanded to do. It verify everything so you are sure the program will print it.Thanks,and wow this looks complicated. I am kinda a noob to Lua.
Posted 17 December 2012 - 01:49 PM
So, I'm pretty new to this, but I can tell what's generally going on with the code. I do need to ask, though: what sort of format would a file have to be in for this program to print it? How does it know when to move onto the next page, for example. Just a little example of a page would be perfect, thanksIs this easier for you to understand? If not, you might want to start out with something easier. :mellow:/>/> Or ask lots of questions here. That's what we're here for. :)/>/>
I basically cut out all the color thingies. printError() is a built-in function that prints in red. :)/>/>
http://pastebin.com/LWCJfR9X