local util = require("util") local item = {} local metatable = { __eq = util.deepEqual, __tostring = function(ser) return textutils.serialise(ser, { compact = true }) end } function item.fromDetail(detail) local detailItem = { name = detail.name, displayName = detail.displayName, tags = detail.tags, itemGroups = detail.itemGroups, maxCount = detail.maxCount } setmetatable(detailItem, metatable) return detailItem end function item.fromString(str) local strItem = textutils.unserialize(str) if type(strItem.name) ~= "string" or type(strItem.displayName) ~= "string" or type(strItem.tags) ~= "table" or type(strItem.itemGroups) ~= "table" or type(strItem.maxCount) ~= "number" then error("Could not parse item: "..str) end setmetatable(strItem, metatable) return strItem end return item