From 9986857ef131f0c0f71b0b8ac8024dbb1de7baf2 Mon Sep 17 00:00:00 2001 From: kepler155c Date: Wed, 21 Mar 2018 11:34:28 -0400 Subject: [PATCH] 1.7.10 compatibility --- apis/meAdapter.lua | 11 ++++++++++- apps/chestManager.lua | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/apis/meAdapter.lua b/apis/meAdapter.lua index dd9c62f..a034062 100644 --- a/apis/meAdapter.lua +++ b/apis/meAdapter.lua @@ -74,6 +74,7 @@ end function MEAdapter:refresh() self.items = nil + local hasItems local s, m = pcall(function() self.items = self.getAvailableItems('all') @@ -81,6 +82,13 @@ function MEAdapter:refresh() Util.merge(v, v.item) convertItem(v) + -- if power has been interrupted, the list will still be returned + -- but all items will have a 0 quantity + -- ensure that the list is valid + if not hasItems then + hasItems = v.qty > 0 + end + if not itemDB:get(v) then itemDB:add(v, v) end @@ -92,9 +100,10 @@ function MEAdapter:refresh() debug(m) end - if s and not Util.empty(self.items) then + if s and hasItems and not Util.empty(self.items) then return self.items end + self.items = nil end function MEAdapter:listItems() diff --git a/apps/chestManager.lua b/apps/chestManager.lua index 5a63db7..cb315db 100644 --- a/apps/chestManager.lua +++ b/apps/chestManager.lua @@ -1180,7 +1180,7 @@ local function learnRecipe(page) if not recipe then debug(results) debug(newRecipe) - error('Failed') + error('Failed - view system log') end newRecipe.count = recipe.count