From 427006d2cb38c9a3b114e0e8c9ebe42bb8450134 Mon Sep 17 00:00:00 2001 From: kepler155c Date: Sun, 25 Nov 2018 21:08:27 -0500 Subject: [PATCH] milo: reduce modem traffic --- milo/MiloRemote.lua | 9 ++++----- milo/plugins/remote.lua | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/milo/MiloRemote.lua b/milo/MiloRemote.lua index a26d8e8..09a7815 100644 --- a/milo/MiloRemote.lua +++ b/milo/MiloRemote.lua @@ -26,7 +26,6 @@ local depositMode = { local displayModes = { [0] = { text = 'A', help = 'Showing all items' }, [1] = { text = 'I', help = 'Showing inventory items' }, - [2] = { text = 'C', help = 'Showing craftable items' }, } local page = UI.Page { @@ -180,8 +179,7 @@ local function filterItems(t, filter, displayMode) if not filter or string.find(v.lname, filter, 1, true) then if not displayMode or displayMode == 0 or - displayMode == 1 and v.count > 0 or - displayMode == 2 and v.has_recipe then + displayMode == 1 and v.count > 0 then table.insert(r, v) end end @@ -371,7 +369,7 @@ shell.openForegroundTab('packages/milo/MiloRemote')]]) self.grid:draw() elseif event.type == 'toggle_display' then - config.displayMode = (config.displayMode + 1) % 3 + config.displayMode = (config.displayMode + 1) % 2 Util.merge(event.button, displayModes[config.displayMode]) event.button:draw() self:applyFilter() @@ -422,9 +420,10 @@ function page:expandList(list) local t = { } for k,v in pairs(list) do local item = splitKey(k) - item.count, item.displayName = v:match('(%d+):(.+)') + item.has_recipe, item.count, item.displayName = v:match('(%d+):(%d+):(.+)') item.count = tonumber(item.count) or 0 item.lname = item.displayName:lower() + item.has_recipe = item.has_recipe == '1' t[k] = item end return t diff --git a/milo/plugins/remote.lua b/milo/plugins/remote.lua index 3230251..1623168 100644 --- a/milo/plugins/remote.lua +++ b/milo/plugins/remote.lua @@ -33,7 +33,7 @@ end local function compactList(list) local c = { } for k,v in pairs(list) do - c[k]= v.count .. ':' .. v.displayName + c[k]= table.concat({ v.has_recipe and 1 or 0, v.count, v.displayName }, ':') end return c end