Added getHomePath() function, move SQLite database to homepath

This commit is contained in:
Timo Smit 2017-01-17 19:26:56 +01:00
parent c0d2aa0e92
commit c261a10c9f
3 changed files with 12 additions and 6 deletions

View file

@ -299,7 +299,7 @@ function sqlite3.isconnected()
end end
function sqlite3.start() function sqlite3.start()
con = env:connect(settings.get("db_file")) con = env:connect(wolfa_getHomePath()..settings.get("db_file"))
if not con then if not con then
return return

View file

@ -45,6 +45,7 @@ local version = "1.1.0-beta"
local release = "26 August 2016" local release = "26 August 2016"
local basepath = nil local basepath = nil
local homepath = nil
-- game related data -- game related data
local currentLevelTime = nil local currentLevelTime = nil
@ -66,6 +67,10 @@ function wolfa_getBasePath()
return basepath return basepath
end end
function wolfa_getHomePath()
return homepath
end
function et_InitGame(levelTime, randomSeed, restartMap) function et_InitGame(levelTime, randomSeed, restartMap)
et.RegisterModname("WolfAdmin "..wolfa_getVersion()) et.RegisterModname("WolfAdmin "..wolfa_getVersion())
@ -73,7 +78,8 @@ function et_InitGame(levelTime, randomSeed, restartMap)
et.trap_SendConsoleCommand(et.EXEC_APPEND, "sets mod_wolfadmin "..wolfa_getVersion()..";") et.trap_SendConsoleCommand(et.EXEC_APPEND, "sets mod_wolfadmin "..wolfa_getVersion()..";")
basepath = string.gsub(et.trap_Cvar_Get("fs_basepath"), "\\", "/").."/"..et.trap_Cvar_Get("fs_game").."/luascripts/wolfadmin/" basepath = string.gsub(et.trap_Cvar_Get("fs_basepath"), "\\", "/").."/"..et.trap_Cvar_Get("fs_game").."/"
homepath = string.gsub(et.trap_Cvar_Get("fs_homepath"), "\\", "/").."/"..et.trap_Cvar_Get("fs_game").."/"
if not (et.trap_Cvar_Get("fs_game") == "noquarter" or et.trap_Cvar_Get("fs_game") == "nq") then if not (et.trap_Cvar_Get("fs_game") == "noquarter" or et.trap_Cvar_Get("fs_game") == "nq") then
outputDebug("Warning! Not running NoQuarter, this may cause bugs. Use at your own risk.") outputDebug("Warning! Not running NoQuarter, this may cause bugs. Use at your own risk.")

View file

@ -25,9 +25,9 @@ function files.ls(directory)
local entries = {} local entries = {}
if platform == "unix" then if platform == "unix" then
command = 'ls -1 "'..wolfa_getBasePath()..directory..'"' command = 'ls -1 "'..wolfa_getBasePath()..'luascripts/wolfadmin/'..directory..'"'
elseif platform == "windows" then elseif platform == "windows" then
command = 'dir "'..wolfa_getBasePath()..directory..'" /b' command = 'dir "'..wolfa_getBasePath()..'luascripts/wolfadmin/'..directory..'" /b'
end end
for filename in io.popen(command):lines() do for filename in io.popen(command):lines() do