Flesh out the printer documentation slightly

This commit is contained in:
Jonathan Coates 2024-01-14 12:25:04 +00:00
parent 4d1e689719
commit b5923c4462
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
2 changed files with 34 additions and 4 deletions

View File

@ -75,8 +75,8 @@ ## Using
```
You should also be careful to only use classes within the `dan200.computercraft.api` package. Non-API classes are
subject to change at any point. If you depend on functionality outside the API, file an issue, and we can look into
exposing more features.
subject to change at any point. If you depend on functionality outside the API (or need to mixin to CC:T), please file
an issue to let me know!
We bundle the API sources with the jar, so documentation should be easily viewable within your editor. Alternatively,
the generated documentation [can be browsed online](https://tweaked.cc/javadoc/).

View File

@ -15,14 +15,44 @@
import java.util.Optional;
/**
* The printer peripheral allows pages and books to be printed.
* The printer peripheral allows printing text onto pages. These pages can then be crafted together into printed pages
* or books.
* <p>
* ## Recipe
* Printers require ink (one of the coloured dyes) and paper in order to function. Once loaded, a new page can be
* started with {@link #newPage()}. Then the printer can be used similarly to a normal terminal; {@linkplain
* #write(Coerced) text can be written}, and {@linkplain #setCursorPos(int, int) the cursor moved}. Once all text has
* been printed, {@link #endPage()} should be called to finally print the page.
* <p>
* ## Recipes
* <div class="recipe-container">
* <mc-recipe recipe="computercraft:printer"></mc-recipe>
* <mc-recipe recipe="computercraft:printed_pages"></mc-recipe>
* <mc-recipe recipe="computercraft:printed_book"></mc-recipe>
* </div>
*
* @cc.usage Print a page titled "Hello" with a small message on it.
*
* <pre>{@code
* local printer = peripheral.find("printer")
*
* -- Start a new page, or print an error.
* if not printer.newPage() then
* error("Cannot start a new page. Do you have ink and paper?")
* end
*
* -- Write to the page
* printer.setPageTitle("Hello")
* printer.write("This is my first page")
* printer.setCursorPos(1, 3)
* printer.write("This is two lines below.")
*
* -- And finally print the page!
* if not printer.endPage() then
* error("Cannot end the page. Is there enough space?")
* end
* }</pre>
* @cc.module printer
* @cc.see cc.strings.wrap To wrap text before printing it.
*/
public class PrinterPeripheral implements IPeripheral {
private final PrinterBlockEntity printer;