From 93625e314794c507df887bf87d889a89d3d2784a Mon Sep 17 00:00:00 2001 From: osmarks Date: Thu, 26 Jul 2018 16:25:42 +0100 Subject: [PATCH] Add NBT hash to cache identifier --- backend-chests.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend-chests.lua b/backend-chests.lua index 75058cd..620cc3d 100644 --- a/backend-chests.lua +++ b/backend-chests.lua @@ -19,16 +19,18 @@ end) local nameCache = {} +-- Get the name for an item in the cache local function get_cache_name(item) local n = item.name .. ":" .. item.damage - print(textutils.serialise(item)) + if item.nbtHash then n = n .. "#" .. item.nbtHash end + return n end -- Gets the display name of the given item (in the given chest peripheral & slot) -- If its name is not cached, cache it. -- If it is, just return the cached name local function cache(item, chest, slot) - local idx = item.name .. ":" .. item.damage + local idx = get_cache_name(item) if nameCache[idx] then return nameCache[idx]