mirror of
https://github.com/kepler155c/opus
synced 2024-12-29 10:00:26 +00:00
36 lines
601 B
Lua
36 lines
601 B
Lua
|
local TableDB = require('tableDB')
|
||
|
|
||
|
local itemDB = TableDB({ fileName = 'usr/config/items.db' })
|
||
|
|
||
|
function itemDB:get(key)
|
||
|
|
||
|
local item = TableDB.get(self, key)
|
||
|
|
||
|
if item then
|
||
|
return item
|
||
|
end
|
||
|
|
||
|
if key[2] ~= 0 then
|
||
|
item = TableDB.get(self, { key[1], 0, key[3] })
|
||
|
if item and item.maxDamage > 0 then
|
||
|
return item
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function itemDB:add(key, item)
|
||
|
|
||
|
if item.maxDamage > 0 then
|
||
|
key = { key[1], 0, key[3] }
|
||
|
end
|
||
|
TableDB.add(self, key, item)
|
||
|
end
|
||
|
|
||
|
function itemDB:makeKey(item)
|
||
|
return { item.name, item.damage, item.nbtHash }
|
||
|
end
|
||
|
|
||
|
itemDB:load()
|
||
|
|
||
|
return itemDB
|