This commit is contained in:
kepler155c@gmail.com 2017-04-17 04:16:12 -04:00
parent 243bcb4ead
commit 17f4f8d9c1
2 changed files with 55 additions and 1 deletions

View File

@ -3,6 +3,7 @@ local Event = require('event')
local UI = require('ui')
local Socket = require('socket')
local Terminal = require('terminal')
local TableDB = require('tableDB')
multishell.setTitle(multishell.getCurrent(), 'Turtles')
UI.Button.defaults.focusIndicator = ' '
@ -30,6 +31,12 @@ local policies = {
{ label = 'turtleSafe' },
}
local itemInfoDB = TableDB({
fileName = 'items.db'
})
itemInfoDB:load()
local page = UI.Page {
moveUp = UI.Button {
x = 5, y = 2,
@ -179,7 +186,13 @@ function page.tabs.inventory:draw()
v.selected = true
end
if v.id then
v.id = v.id:gsub('.*:(.*)', '%1')
local item = itemInfoDB:get({ v.id, v.dmg })
debug(v)
if item then
v.id = item.displayName
else
v.id = v.id:gsub('.*:(.*)', '%1')
end
end
end
end

41
apps/itemsDB.lua Normal file
View 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()