Lua debugger part 1

This commit is contained in:
kepler155c@gmail.com
2020-05-23 21:44:55 -06:00
parent 2c27787f27
commit cb58a553f5
11 changed files with 923 additions and 349 deletions

View File

@@ -16,12 +16,12 @@ UI:configure('Equipment', ...)
local equipment = device.neuralInterface.getEquipment()
local slots = {
'primary',
'offhand',
'boots',
'leggings',
'chest',
'helmet',
'primary',
'offhand',
'boots',
'leggings',
'chest',
'helmet',
}
local page = UI.Page {
@@ -34,29 +34,29 @@ local page = UI.Page {
grid = UI.Grid {
y = 2,
columns = {
{ heading = 'Slot', key = 'index', width = 7 },
{ heading = 'Slot', key = 'index', width = 7 },
{ heading = 'Name', key = 'displayName' },
{ heading = 'Count', key = 'count', width = 5, align = 'right' },
},
sortColumn = 'index',
accelerators = {
grid_select = 'show_detail',
},
getDisplayValues = function(_, row)
row = Util.shallowCopy(row)
if row.name then
local item = itemDB:get(
table.concat({ row.name, row.damage, row.nbtHash }, ':'),
function()
return equipment.getItemMeta(row.index)
end)
row.displayName = item.displayName
else
row.displayName = 'empty'
end
row.index = slots[row.index]
return row
end,
sortColumn = 'index',
accelerators = {
grid_select = 'show_detail',
},
getDisplayValues = function(_, row)
row = Util.shallowCopy(row)
if row.name then
local item = itemDB:get(
table.concat({ row.name, row.damage, row.nbtHash }, ':'),
function()
return equipment.getItemMeta(row.index)
end)
row.displayName = item.displayName
else
row.displayName = 'empty'
end
row.index = slots[row.index]
return row
end,
},
accelerators = {
[ 'control-q' ] = 'quit',
@@ -77,58 +77,58 @@ local page = UI.Page {
accelerators = {
grid_select = 'inspect',
},
},
show = function(self, slot)
local detail = equipment.getItemMeta(slot.index)
local t = { }
for k,v in pairs(detail) do
table.insert(t, {
name = k,
value = v,
})
end
self.grid:setValues(t)
self.grid:setIndex(1)
UI.SlideOut.show(self)
end,
},
enable = function(self)
self:refresh()
UI.Page.enable(self)
end,
refresh = function(self)
local t = { }
local list = equipment.list()
for i = 1, equipment.size() do
local v = list[i] or { }
v.index = i
table.insert(t, v)
end
self.grid:setValues(t)
self.grid:draw()
end,
eventHandler = function(self, event)
if event.type == 'quit' then
UI:quit()
},
show = function(self, slot)
local detail = equipment.getItemMeta(slot.index)
local t = { }
for k,v in pairs(detail) do
table.insert(t, {
name = k,
value = v,
})
end
self.grid:setValues(t)
self.grid:setIndex(1)
UI.SlideOut.show(self)
end,
},
enable = function(self)
self:refresh()
UI.Page.enable(self)
end,
refresh = function(self)
local t = { }
local list = equipment.list()
for i = 1, equipment.size() do
local v = list[i] or { }
v.index = i
table.insert(t, v)
end
self.grid:setValues(t)
self.grid:draw()
end,
eventHandler = function(self, event)
if event.type == 'quit' then
UI:quit()
elseif event.type == 'show_detail' then
if event.selected.name then
self.detail:show(event.selected)
end
elseif event.type == 'show_detail' then
if event.selected.name then
self.detail:show(event.selected)
end
elseif event.type == 'drop' then
local selected = self.grid:getSelected()
equipment.drop(selected.index)
self:refresh()
elseif event.type == 'drop' then
local selected = self.grid:getSelected()
equipment.drop(selected.index)
self:refresh()
elseif event.type == 'suck' then
local selected = self.grid:getSelected()
equipment.suck(selected.index)
self:refresh()
end
elseif event.type == 'suck' then
local selected = self.grid:getSelected()
equipment.suck(selected.index)
self:refresh()
end
UI.Page.eventHandler(self, event)
end,
UI.Page.eventHandler(self, event)
end,
}
Event.onInterval(1, function()