Skip to content
This repository was archived by the owner on Aug 20, 2020. It is now read-only.

Commit 1a36d6a

Browse files
committed
Improve a bit the code...
..., remove one deprecated function, use mod.conf for name and description.
1 parent 124bdb7 commit 1a36d6a

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

abstraction.lua

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
local modname = minetest.get_current_modname()
2-
32
local thismod = _G[modname]
43

54
---- Table creation & deletion
@@ -33,13 +32,15 @@ function thismod.create_table_sql(name, params)
3332
end
3433
return 'CREATE TABLE ' .. name .. ' (' .. table.concat(lines, ',') .. ')'
3534
end
35+
3636
function thismod.create_table(name, params)
3737
thismod.conn:query(thismod.create_table_sql(name, params))
3838
end
3939

4040
function thismod.drop_table_sql(name)
4141
return 'DROP TABLE ' .. name
4242
end
43+
4344
function thismod.drop_table(name)
4445
thismod.conn:query(thismod.drop_table_sql(name))
4546
end
@@ -96,6 +97,7 @@ end
9697
function thismod.prepare_select_sql(tablename, colnames, where)
9798
return 'SELECT ' .. table.concat(colnames, ',') .. ' FROM ' .. tablename .. ' WHERE ' .. where
9899
end
100+
99101
function thismod.prepare_select(tablename, cols, where, wheretypes)
100102
local colnames, coltypes = {}, {}
101103
for _, col in ipairs(cols) do
@@ -104,4 +106,4 @@ function thismod.prepare_select(tablename, cols, where, wheretypes)
104106
end
105107
local stmt = thismod.conn:prepare(thismod.prepare_select_sql(tablename, colnames, where))
106108
return stmt, stmt:bind_params(wheretypes), stmt:bind_result(coltypes)
107-
end
109+
end

init.lua

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ function thismod.mklog(level, modname)
1111
minetest.log(level, "[" .. modname .. "] " .. str)
1212
end
1313
end
14+
1415
local LogI = thismod.mklog('action', modname)
1516
local LogE = thismod.mklog('error', modname)
1617

1718
local singleplayer = minetest.is_singleplayer() -- Caching is OK since you can't open a game to
1819
-- multiplayer unless you restart it.
19-
if minetest.setting_get(modname .. '.enable_singleplayer') ~= 'true' and singleplayer then
20+
21+
if minetest.settings:get(modname .. '.enable_singleplayer') ~= 'true' and singleplayer then
2022
LogI("Not enabling because of singleplayer game")
2123
return
2224
end
@@ -202,6 +204,7 @@ local function ping()
202204
end
203205
minetest.after(1800, ping)
204206
end
207+
205208
minetest.after(10, ping)
206209

207210
local shutdown_callbacks = {}
@@ -229,4 +232,4 @@ function thismod.table_exists(name)
229232
return exists
230233
end
231234

232-
dofile(modpath .. '/abstraction.lua')
235+
dofile(modpath .. '/abstraction.lua')

mod.conf

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
name = mysql_base
2+
description = MySQL connector (requires LuaJIT FFI).

0 commit comments

Comments
 (0)