This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
bruegge's profile picture

ME.exportItem tesserac not exportable

Started by bruegge, 25 February 2018 - 01:30 PM
bruegge #1
Posted 25 February 2018 - 02:30 PM
hi, I am new in this forum…

I am trying to get a tesseract out of my ME system …
First, I print out all items which are inside the ME system.
The following code gives me the following result:

Code:
function GetItemsME()
local ME = peripheral.wrap("back")
local items = ME.getAvailableItems()

for k, v in pairs(items) do
for a, b in pairs(v) do
print("a: "..a.." b: "..tostring(B)/>.." ")

if a == "fingerprint" then
for c,d in pairs(B)/> do
print("c: "..c.. " d: "..d.." ")
end
end
end
end
end

Result:

a: is_fluid b: false
a: size b: 1
a: is_item b: true
a: is_craftable b: false
a: fingerprint b: table: 10d1dddb
c: id d: ThermalExpansion:Tesseract
c: dmg d: 0
c: nbt_hash d: 4e4dd2b38b5a3599de9179dfa08246a6


now: I am trying to pull out the item to a chest.
this is the code:


function PutToChest()
local ME = peripheral.wrap("back")
fingerprint = {id = "ThermalExpansion:Tesseract", dmg = 0}
ME.exportItem(fingerprint,"down",1)
end

but then the errormessage appears:
test:32: Can't find item fringerprint
ThermalExpansion:Tesseract:0:null

if I do the same with cobblestone, everything is working fine.
I figured out, that it does not work with items, with have nbt_hash.
how can I change that? and what is nbt_hash?
also: is there a possibility to get more information about the items?

Thanks a lot!
Lyqyd #2
Posted 25 February 2018 - 11:50 PM
Moved to Ask a Pro.
Bomb Bloke #3
Posted 26 February 2018 - 10:12 AM
but then the errormessage appears:
test:32: Can't find item fringerprint
ThermalExpansion:Tesseract:0:null

Even putting aside the mysterious "fringerprint" typo, that doesn't sound right - are you sure you're not wrapping "fingerprint" in quotes when you pass it to the exportItem function? I can't see any other way that it'd be able to include that specific term as a string within the error, otherwise…

If you want to pass the fingerprint table you defined on the line above, be sure to omit the quotes!
bruegge #4
Posted 26 February 2018 - 10:09 PM
thank you for your fast response!
ohh year… sure it is not fringerprint… it is fingerprint… but that mistake comes from writing down the errormessage.

I just pass the id = "ThermalExpansion:Tesseract", dmg = 0 but the error only pop up, if the item I am looking for has this nbt_hash.
I don't understand what nbt_hash is… can you please tell me?

4e4dd2b38b5a3599de9179dfa08246a6 also does not look like a table or something else. maybe it is an ID, which is unique, but why does is not work?

I am new to open peripherals, but I can see the power of it =). I want to manage my systems more propper.

BTW: I tried to but the id as a variable read out from "getAvailableItems" and also by writing the id into a string. both have the same results :/
I forgot to write the versions here: computercraft 1.75 . openPeripherals 0.5.1 ,applied energistics 2 and minecraft 1.7.10 with the modpack beachblocks modsplosion
Bomb Bloke #5
Posted 27 February 2018 - 01:58 AM
To be honest, I'm not sure what an nbt_hash is either!

I can tell you that hashes in general are usually used to confirm two objects match, though. The idea is that you take a blob of data you want to compare - of any size, it can be tiny or huge - and run it through a hashing algorithm. This gets you a number (always of the same size, no matter how much data you're hashing), which is then usually represented using hexadecimal. Every time you hash an exact copy of that data you'll get the exact same hash value, but it's usually not possible to convert back the other way.

One use for hashes is when downloading large files. At the end of the process your system might hash the result, and compare that to a hash value the source server provides. If the two hashes match, then your computer knows the file was downloaded without corruption. A hash used in this way is often referred to as a checksum - and they're a lot like fingerprints.

Another use is to help with password security. When you create a password, the server doesn't store it, but instead uses it to generate a hash and stores that. When you try to use the password later, what you type is hashed and compared to what the server has. This way, if someone takes over the server, they don't actually get to see what your password is (which would be a big deal if you consider how many people use the same password on different sites!), because the server never stored it!

I would guess that if you simply include the hash in your table, exportItem might be appeased?

{id = "ThermalExpansion:Tesseract", dmg = 0, nbt_hash = 4e4dd2b38b5a3599de9179dfa08246a6}
Stekeblad #6
Posted 27 February 2018 - 08:46 AM
I don't understand what nbt_hash is… can you please tell me?

Tesseracts remember the settings when you break it, right? So maybe the settings is stored as NBT. Some NBT tags may hold a lot of data or data not in text form so I guess that may be one of the reasons openPeripherals decided to print a hash.
SquidDev #7
Posted 27 February 2018 - 01:58 PM
Exposing the raw NBT to the user is a bit problematic, as it breaks the fourth wall (and I guess could leak some internal data about an item). In order to prevent this, OpenPeripherals just exposes an md5 hash of the item's NBT.

This obviously means can't extract any useful information from it, but it allows you to determine if two items are "equal". Consequently, items are only equal if their NBT hashes are equal - as BombBloke rightly says, you'll need to include it in your call to exportItem.
bruegge #8
Posted 27 February 2018 - 02:05 PM
thank you Bomb Bloke!

its working now! you are right, I just had to put the nbt_hash inside the table. now my me-system knows which item it is :)/>

thanks a lot!

best regards Bruegge :)/>