←  Command Programs

ComputerCraft | Programmable Computers for Minecraft

»

cPrint: Print books with Command Computers

Bomb Bloke's Photo Bomb Bloke 31 Oct 2015

cPrint API: pastebin get QP8yFSPW cprint

PrintShop script: pastebin get juQeX2fS printshop

People keep complaining about the difficulty of creating printed books. It occurred to me that Command Computers could be used to "cheat", making the process much simpler.

So here we have two bits of code: an API that returns terminal objects that can be converted into books, and a script that uses said API to offer books to players.

cPrint API Usage

PrintShop Script Usage

Video

Version History

Edited by Bomb Bloke, 02 November 2015 - 03:23 AM.
Quote

The_Puzzlemaker's Photo The_Puzzlemaker 01 Nov 2015

Any screenshots? I want to see how the PrintShop API would look like.
Quote

Awe2K's Photo Awe2K 01 Nov 2015

Alright, it seems to be a cool idea to allow player to simultaneously print whole book.
However, I've experienced some problems trying it (your program just printed book contents and tag info to chat):
Screenshot in spoiler.
Spoiler
Quote

Bomb Bloke's Photo Bomb Bloke 02 Nov 2015

View PostRemovia, on 01 November 2015 - 12:49 PM, said:

Any screenshots? I want to see how the PrintShop API would look like.

The PrintShop boils down to a basic "here's a list"-interface, so it's not very interesting. I've gone ahead an added a short video to the OP anyway.

View PostAwe2K, on 01 November 2015 - 05:30 PM, said:

However, I've experienced some problems trying it (your program just printed book contents and tag info to chat):

Seems I forgot to re-escape quotes before passing the text to the command system - I didn't test the particular book you tried it with (even though it happened to be first on the list), and somehow the books I did try didn't have them!

If you "rm cprint" and allow it to be redownloaded, it should be fixed now. Thanks for the report! :)
Quote

elopus001's Photo elopus001 02 Nov 2015

Thanks for making this. I'm working on using it for generating logs for my other scripts. Is there a way to make these place in a chest?
Quote

Bomb Bloke's Photo Bomb Bloke 02 Nov 2015

If you don't specify a target when printing, the API will generate a chest above the Command Computer (assuming something isn't already there), and then a hopper with the book(s) above that (which gets removed once the books have dropped to the chest below).

It's done this way as there isn't a method of directly adding items to an inventory using commands - at least, not under MC 1.7.10. Attempting to place a new chest each time would delete its prior contents.

If you wanted to have the PrintShop script call the API in this manner, change the line around 263 to:

book.printBook(nil, copies)

Books may not be the best way to store logs, however - they're a pretty way of distributing information to players, but you might be better off storing data you actually want to "use" into files on your system's drives (which you can send off to pastebin, if you're having trouble accessing them from there). Eg:

local output = fs.open("myLog.txt", "w")  -- Or use "a" instead of "w", if you want "append" mode.
output.writeLine("stuff")
output.close()
Quote

elopus001's Photo elopus001 02 Nov 2015

View PostBomb Bloke, on 02 November 2015 - 06:33 AM, said:

Books may not be the best way to store logs, however - they're a pretty way of distributing information to players, but you might be better off storing data you actually want to "use" into files on your system's drives (which you can send off to pastebin, if you're having trouble accessing them from there). Eg:

local output = fs.open("myLog.txt", "w")  -- Or use "a" instead of "w", if you want "append" mode.
output.writeLine("stuff")
output.close()

Ok. I'm already using the file method to store all the block locations. I'm just using this to create a book of what type of building is at what chunk in my city generator.
Edited by elopus001, 02 November 2015 - 01:40 PM.
Quote