Posted 26 June 2017 - 12:24 AM
Printerm API
Have you ever wanted to have an easy interface to a printer? (pretend you have)
Is interacting with a printer confusing? (pretend it is)
Do you want to be able to term.redirect to a printer? (pretend you do)
In that case, this API is for you!
Wrapping all functions required of a terminal object, (down to British spellings) and creating an object you can use took a while but it works (to the best of my knowledge, haven't tested fringe cases) as good as I can get it.
Example (with Printerm):
Example (without):
The benefits of this API don't become apparent in this example. Let's say you have a program that displays info to a screen. (Lots of info, like the status of all machines in your base.) Using printerm, you get the benefit of auto-word-wrap (print() and write()) as well as the convenience of a printout.
How to get the API (link):
Have you ever wanted to have an easy interface to a printer? (pretend you have)
Is interacting with a printer confusing? (pretend it is)
Do you want to be able to term.redirect to a printer? (pretend you do)
In that case, this API is for you!
Wrapping all functions required of a terminal object, (down to British spellings) and creating an object you can use took a while but it works (to the best of my knowledge, haven't tested fringe cases) as good as I can get it.
Example (with Printerm):
os.loadAPI("printerm")
local paperTerm = printerm.getTerm(...)
local oldTerm = term.redirect(paperTerm)
print("Testing 1,2,3")
paperTerm.endPage()
term.redirect(oldTerm)
Example (without):
local printer = peripheral.wrap(...)
printer.newPage()
printer.write("Testing 1,2,3")
printer.endPage()
The benefits of this API don't become apparent in this example. Let's say you have a program that displays info to a screen. (Lots of info, like the status of all machines in your base.) Using printerm, you get the benefit of auto-word-wrap (print() and write()) as well as the convenience of a printout.
How to get the API (link):
pastebin get GzSunvu9 printerm
Documentation is here.
Edited on 25 June 2017 - 10:54 PM