mirror of
https://github.com/kepler155c/opus
synced 2025-02-02 18:39:09 +00:00
item db
This commit is contained in:
parent
243bcb4ead
commit
17f4f8d9c1
@ -3,6 +3,7 @@ local Event = require('event')
|
|||||||
local UI = require('ui')
|
local UI = require('ui')
|
||||||
local Socket = require('socket')
|
local Socket = require('socket')
|
||||||
local Terminal = require('terminal')
|
local Terminal = require('terminal')
|
||||||
|
local TableDB = require('tableDB')
|
||||||
|
|
||||||
multishell.setTitle(multishell.getCurrent(), 'Turtles')
|
multishell.setTitle(multishell.getCurrent(), 'Turtles')
|
||||||
UI.Button.defaults.focusIndicator = ' '
|
UI.Button.defaults.focusIndicator = ' '
|
||||||
@ -30,6 +31,12 @@ local policies = {
|
|||||||
{ label = 'turtleSafe' },
|
{ label = 'turtleSafe' },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local itemInfoDB = TableDB({
|
||||||
|
fileName = 'items.db'
|
||||||
|
})
|
||||||
|
|
||||||
|
itemInfoDB:load()
|
||||||
|
|
||||||
local page = UI.Page {
|
local page = UI.Page {
|
||||||
moveUp = UI.Button {
|
moveUp = UI.Button {
|
||||||
x = 5, y = 2,
|
x = 5, y = 2,
|
||||||
@ -179,11 +186,17 @@ function page.tabs.inventory:draw()
|
|||||||
v.selected = true
|
v.selected = true
|
||||||
end
|
end
|
||||||
if v.id then
|
if v.id then
|
||||||
|
local item = itemInfoDB:get({ v.id, v.dmg })
|
||||||
|
debug(v)
|
||||||
|
if item then
|
||||||
|
v.id = item.displayName
|
||||||
|
else
|
||||||
v.id = v.id:gsub('.*:(.*)', '%1')
|
v.id = v.id:gsub('.*:(.*)', '%1')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
self:adjustWidth()
|
self:adjustWidth()
|
||||||
self:update()
|
self:update()
|
||||||
UI.Grid.draw(self)
|
UI.Grid.draw(self)
|
||||||
|
41
apps/itemsDB.lua
Normal file
41
apps/itemsDB.lua
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
local injector = requireInjector or load(http.get('http://pastebin.com/raw/c0TWsScv').readAll())()
|
||||||
|
require = injector(getfenv(1))
|
||||||
|
|
||||||
|
local RefinedProvider = require('refinedProvider')
|
||||||
|
local TableDB = require('tableDB')
|
||||||
|
|
||||||
|
local controller = RefinedProvider()
|
||||||
|
if not controller:isValid() then
|
||||||
|
error('Refined storage controller not found')
|
||||||
|
end
|
||||||
|
|
||||||
|
local itemInfoDB = TableDB({
|
||||||
|
fileName = 'items.db'
|
||||||
|
})
|
||||||
|
|
||||||
|
itemInfoDB:load()
|
||||||
|
|
||||||
|
local items = controller:listItems()
|
||||||
|
|
||||||
|
local keys = {
|
||||||
|
'fields',
|
||||||
|
'damage',
|
||||||
|
'displayName',
|
||||||
|
'maxCount',
|
||||||
|
'maxDamage',
|
||||||
|
'name',
|
||||||
|
'nbtHash',
|
||||||
|
'rawName',
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, item in pairs(items) do
|
||||||
|
|
||||||
|
local t = { }
|
||||||
|
for _,key in pairs(keys) do
|
||||||
|
t[key] = item[key]
|
||||||
|
end
|
||||||
|
|
||||||
|
itemInfoDB:add({ item.name, item.damage, item.nbtHash }, t)
|
||||||
|
end
|
||||||
|
|
||||||
|
itemInfoDB:flush()
|
Loading…
Reference in New Issue
Block a user