when you get the item OpenPeripheral will return a table of information on the book. it will be something like so
{
id = 403,
name = "Enchanted Book",
maxdmg = 0,
rawName = "item.enchantedbook",
dmg = 0,
maxSize = 1,
ench = {
"Knockback II",
}
qty = 1
}
so the following code will loop through a chest and print out all the enchantments on any enchanted item
local chest = peripheral.wrap("left")
local contents = chest.getAllStacks()
for index, item in pairs(contents) do
if item.ench then --# if there is an enchantment(s) on the item
print("Found a ", item.name, " with the enchantments: ", table.concat(item.ench, ', '))
end
end
so the above code will also output enchantments on tools, armour, etc.