cleanup + monitorManager
This commit is contained in:
16
apis/configurator.lua
Normal file
16
apis/configurator.lua
Normal file
@@ -0,0 +1,16 @@
|
||||
requireInjector(getfenv(1))
|
||||
|
||||
local Util = require('util')
|
||||
|
||||
local Configurator = { }
|
||||
|
||||
function Configurator.get()
|
||||
print('Select device')
|
||||
for k,v in pairs(device) do
|
||||
Util.print('%s [%s]', v.name, v.side)
|
||||
end
|
||||
end
|
||||
|
||||
Configurator.get()
|
||||
|
||||
return Configurator
|
||||
@@ -1,5 +1,6 @@
|
||||
local Util = require('util')
|
||||
local nameDB = require('nameDB')
|
||||
local TableDB = require('tableDB')
|
||||
local Util = require('util')
|
||||
|
||||
local itemDB = TableDB({ fileName = 'usr/config/items.db' })
|
||||
|
||||
@@ -59,7 +60,9 @@ function itemDB:getName(item)
|
||||
if detail then
|
||||
return detail.displayName
|
||||
end
|
||||
return item.name .. ':' .. item.damage
|
||||
|
||||
-- fallback to nameDB
|
||||
return nameDB:getName(item.name .. ':' .. item.damage)
|
||||
end
|
||||
|
||||
function itemDB:load()
|
||||
|
||||
32
apis/nameDB.lua
Normal file
32
apis/nameDB.lua
Normal file
@@ -0,0 +1,32 @@
|
||||
local JSON = require('json')
|
||||
local TableDB = require('tableDB')
|
||||
|
||||
local nameDB = TableDB()
|
||||
|
||||
function nameDB:load()
|
||||
|
||||
local blocks = JSON.decodeFromFile('usr/etc/blocks.json')
|
||||
|
||||
if not blocks then
|
||||
error('Unable to read usr/etc/blocks.json')
|
||||
end
|
||||
|
||||
for strId, block in pairs(blocks) do
|
||||
local strId = 'minecraft:' .. strId
|
||||
if type(block.name) == 'string' then
|
||||
self.data[strId .. ':0'] = block.name
|
||||
else
|
||||
for nid,name in pairs(block.name) do
|
||||
self.data[strId .. ':' .. (nid-1)] = name
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function nameDB:getName(strId)
|
||||
return self.data[strId] or strId
|
||||
end
|
||||
|
||||
nameDB:load()
|
||||
|
||||
return nameDB
|
||||
Reference in New Issue
Block a user