diff options
author | ubq323 <ubq323@ubq323.website> | 2023-03-24 21:11:10 +0000 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2023-03-24 21:11:10 +0000 |
commit | e77609c5bc8b44aa22ef88063246fd05add5e705 (patch) | |
tree | 1829e2098e40f7fad82af8707bd8a359edd2be1d /server/db.lua | |
parent | 0927f9297c06525a453b4aad44fa4c2916c75906 (diff) |
use lmdb for world storage; plus other small things
support numpad 8456 for movement in addition to wasd
refactor server and add player module
update outdated documentation slightly
Diffstat (limited to 'server/db.lua')
-rw-r--r-- | server/db.lua | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/server/db.lua b/server/db.lua new file mode 100644 index 0000000..4208aeb --- /dev/null +++ b/server/db.lua @@ -0,0 +1,15 @@ +local lmdb = require'lmdb' +local env = lmdb.open('data',{maxdbs=16}) +local function get_db(dbname, writeable) + -- shortcut + if writeable == nil then writeable = false end + local txn = assert(env:txn_begin(writeable),"couldn't begin txn") + local the_db = assert(txn:open(dbname), "couldn't open db") + return txn,the_db +end + + +return { + env=env, + get_db=get_db, +} |