reduce net traffic
This commit is contained in:
@@ -69,8 +69,8 @@ local page = UI.Page {
|
|||||||
tabTitle = 'Inv',
|
tabTitle = 'Inv',
|
||||||
columns = {
|
columns = {
|
||||||
{ heading = '', key = 'index', width = 2 },
|
{ heading = '', key = 'index', width = 2 },
|
||||||
{ heading = '', key = 'qty', width = 2 },
|
{ heading = '', key = 'count', width = 2 },
|
||||||
{ heading = 'Inventory', key = 'id', width = UI.term.width - 7 },
|
{ heading = 'Inventory', key = 'key', width = UI.term.width - 7 },
|
||||||
},
|
},
|
||||||
disableHeader = true,
|
disableHeader = true,
|
||||||
sortColumn = 'index',
|
sortColumn = 'index',
|
||||||
@@ -208,15 +208,28 @@ function page.tabs.inventory:draw()
|
|||||||
local t = page.turtle
|
local t = page.turtle
|
||||||
Util.clear(self.values)
|
Util.clear(self.values)
|
||||||
if t then
|
if t then
|
||||||
for _,v in ipairs(t.inventory) do
|
for k,v in pairs(t.inv or { }) do -- new method (less data)
|
||||||
if v.qty > 0 then
|
local index, count = k:match('(%d+),(%d+)')
|
||||||
|
v = {
|
||||||
|
index = tonumber(index),
|
||||||
|
key = v,
|
||||||
|
count = tonumber(count),
|
||||||
|
}
|
||||||
|
table.insert(self.values, v)
|
||||||
|
end
|
||||||
|
|
||||||
|
for _,v in pairs(t.inventory or { }) do
|
||||||
|
if v.count > 0 then
|
||||||
table.insert(self.values, v)
|
table.insert(self.values, v)
|
||||||
if v.index == t.slotIndex then
|
end
|
||||||
v.selected = true
|
end
|
||||||
end
|
|
||||||
if v.id then
|
for _,v in pairs(self.values) do
|
||||||
v.id = itemDB:getName(v)
|
if v.index == t.slotIndex then
|
||||||
end
|
v.selected = true
|
||||||
|
end
|
||||||
|
if v.key then
|
||||||
|
v.key = itemDB:getName(v.key)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -236,7 +249,6 @@ function page.tabs.inventory:eventHandler(event)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function page.tabs.scripts:draw()
|
function page.tabs.scripts:draw()
|
||||||
|
|
||||||
Util.clear(self.values)
|
Util.clear(self.values)
|
||||||
local files = fs.list(SCRIPTS_PATH)
|
local files = fs.list(SCRIPTS_PATH)
|
||||||
for _,path in pairs(files) do
|
for _,path in pairs(files) do
|
||||||
|
|||||||
Reference in New Issue
Block a user