builder improvements - resource manager

This commit is contained in:
kepler155c@gmail.com
2017-07-02 10:05:10 -04:00
parent 7f99c0c69a
commit 027f386ed1
9 changed files with 1009 additions and 707 deletions

35
sys/apis/itemDB.lua Normal file
View File

@@ -0,0 +1,35 @@
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