Jump to content




cPrint: Print books with Command Computers

command

6 replies to this topic

#1 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,096 posts
  • LocationTasmania (AU)

Posted 31 October 2015 - 07:54 AM

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.


#2 The_Puzzlemaker

  • Members
  • 7 posts
  • LocationGlobal Domination HQ, UKRI

Posted 01 November 2015 - 12:49 PM

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

#3 Awe2K

  • Members
  • 38 posts
  • LocationSomewhere near keyboard

Posted 01 November 2015 - 05:30 PM

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


#4 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,096 posts
  • LocationTasmania (AU)

Posted 02 November 2015 - 03:20 AM

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! :)

#5 elopus001

  • Members
  • 15 posts

Posted 02 November 2015 - 03:38 AM

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?

#6 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,096 posts
  • LocationTasmania (AU)

Posted 02 November 2015 - 06:33 AM

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()


#7 elopus001

  • Members
  • 15 posts

Posted 02 November 2015 - 01:38 PM

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.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users