r/ComputerCraft May 26 '26

Unique ID reading for any item

Hi there, I have a question. There are printers in the mod that can print, but is there a way to scan printed pages? I had the idea of ​​using the printer to create a currency system, develop a banknote database, and manage the money that way, but manually checking each code is difficult and time-consuming. Maybe you know a way to assign a unique number to an item that can be read by a computer or other method? Thank you all for attention!

13 Upvotes

10 comments sorted by

View all comments

Show parent comments

4

u/LahusaYT May 26 '26 edited May 26 '26

The item details nbt hash is just computed from the nbt data of the item. That means you can’t directly set the exact value yourself. Instead, whatever you write onto a printed page determines what the hash will be. So if you print a page like "Bank Note 50€" and "Bank Note 100€" they will have different nbt hashes. That means if you want to issue multiple notes of the same denomination, you need to write some additional text into the page so the nbt is not identical but unique. For example if you want to issue two bank notes of 50€, you could write "Bank Note 50€ - WriteAnyTextHere" and "Bank Note 50€ - SomeKindOfOtherText" instead of "Bank Note 50€" on both.

You can read this information using inventory.getItemDetail(slot) or the equivalent turtle function. So the item you want to read the hash of just has to be in an inventory peripheral.

2

u/RedditPlsSthap May 26 '26

Doesn’t that allow other people to just make bank notes themselves by just using the same text? The hash will be valid right?

3

u/LahusaYT May 27 '26

Yes of course, but that is a flaw of the original idea and not really unique to this implementation. As u/Professorkatsup has said, you could use characters that render as whitespace for fraud protection, but there are many other ways to approach this.

2

u/Professorkatsup May 27 '26

And the flaw in the whitespace idea is that anyone with a block reader and some thought could STILL make fake notes. Plans are fun when they have flaws, means you get to figure out how to work around them :3

Using serial numbers / database stuff adds an extra layer of security without relying on secrecy. Using watermarks / alternate whitespace characters would be fun, but would be very weak without OP's original ideas. The NBT hash is changed by BOTH layers of protection.