diff --git a/abstraction.lua b/abstraction.lua index 9a62ee9..9e4e9ee 100644 --- a/abstraction.lua +++ b/abstraction.lua @@ -1,5 +1,4 @@ local modname = minetest.get_current_modname() - local thismod = _G[modname] ---- Table creation & deletion @@ -33,6 +32,7 @@ function thismod.create_table_sql(name, params) end return 'CREATE TABLE ' .. name .. ' (' .. table.concat(lines, ',') .. ')' end + function thismod.create_table(name, params) thismod.conn:query(thismod.create_table_sql(name, params)) end @@ -40,6 +40,7 @@ end function thismod.drop_table_sql(name) return 'DROP TABLE ' .. name end + function thismod.drop_table(name) thismod.conn:query(thismod.drop_table_sql(name)) end @@ -96,6 +97,7 @@ end function thismod.prepare_select_sql(tablename, colnames, where) return 'SELECT ' .. table.concat(colnames, ',') .. ' FROM ' .. tablename .. ' WHERE ' .. where end + function thismod.prepare_select(tablename, cols, where, wheretypes) local colnames, coltypes = {}, {} for _, col in ipairs(cols) do @@ -104,4 +106,4 @@ function thismod.prepare_select(tablename, cols, where, wheretypes) end local stmt = thismod.conn:prepare(thismod.prepare_select_sql(tablename, colnames, where)) return stmt, stmt:bind_params(wheretypes), stmt:bind_result(coltypes) -end +end \ No newline at end of file diff --git a/init.lua b/init.lua index 6ef9f3a..9950898 100644 --- a/init.lua +++ b/init.lua @@ -11,12 +11,14 @@ function thismod.mklog(level, modname) minetest.log(level, "[" .. modname .. "] " .. str) end end + local LogI = thismod.mklog('action', modname) local LogE = thismod.mklog('error', modname) local singleplayer = minetest.is_singleplayer() -- Caching is OK since you can't open a game to -- multiplayer unless you restart it. -if minetest.setting_get(modname .. '.enable_singleplayer') ~= 'true' and singleplayer then + +if minetest.settings:get(modname .. '.enable_singleplayer') ~= 'true' and singleplayer then LogI("Not enabling because of singleplayer game") return end @@ -202,6 +204,7 @@ local function ping() end minetest.after(1800, ping) end + minetest.after(10, ping) local shutdown_callbacks = {} @@ -229,4 +232,4 @@ function thismod.table_exists(name) return exists end -dofile(modpath .. '/abstraction.lua') +dofile(modpath .. '/abstraction.lua') \ No newline at end of file diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..9d7904a --- /dev/null +++ b/mod.conf @@ -0,0 +1,2 @@ +name = mysql_base +description = MySQL connector (requires LuaJIT FFI). \ No newline at end of file