Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- 1) Wrap your Block Reader (here on the “back” of the computer)
- local reader = peripheral.wrap("back")
- if not reader or peripheral.getType("back") ~= "blockReader" then
- error("Block Reader not found on back")
- end
- -- 2) Grab the full chest NBT
- local data = reader.getBlockData()
- if not data or type(data.Items) ~= "table" then
- error("No chest data found")
- end
- -- 3) Helper to recursively dump a table
- local function dump(t, indent)
- indent = indent or ""
- for k, v in pairs(t) do
- if type(v) == "table" then
- print(indent .. tostring(k) .. ":")
- dump(v, indent .. " ")
- else
- print(indent .. tostring(k) .. " = " .. tostring(v))
- end
- end
- end
- -- 4) Iterate your slots
- for _, item in ipairs(data.Items) do
- print(string.format("Slot %d - %s x%d", item.Slot, item.id, item.Count))
- -- 5) Dump full tag to inspect nutrition/expiration fields
- if item.tag then
- print(" Full NBT tag for this stack:")
- dump(item.tag, " ")
- else
- print(" No tag data present on this item.")
- end
- -- 6) Once you know the path, you can extract directly:
- --[[
- local food = item.tag.FoodData
- if food then
- print(" Nutrition: " .. tostring(food.Nutrition))
- print(" Expiration (ticks): " .. tostring(food.Expiration))
- end
- ]]
- print("---")
- end
Add Comment
Please, Sign In to add comment