-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathserverLauncher.lua
More file actions
45 lines (40 loc) · 1.49 KB
/
serverLauncher.lua
File metadata and controls
45 lines (40 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
local util = require("common.lib.util")
util.addToCPath("./common/lib/??")
util.addToCPath("./server/lib/??")
local logger = require("common.lib.logger")
if arg[1] == "debug" then
-- for debugging in visual studio code
if os.getenv("LOCAL_LUA_DEBUGGER_VSCODE") == "1" then
-- VS Code / VS Codium
require("lldebugger").start()
elseif pcall(function() require("mobdebug") end) then
-- ZeroBrane
-- afaik there is no good way to detect whether the game was started with zerobrane other than trying the require and succeeding
require("mobdebug").start()
require('mobdebug').coro()
end
logger.setLogLevel(logger.levels.DEBUG)
else
logger.setLogLevel(logger.levels.INFO)
end
-- We must launch the server from the root directory so all the requires are the right path relatively.
require("server.server_globals")
require("server.tests.ServerTests")
require("server.tests.LeaderboardTests")
require("server.tests.RoomTests")
require("server.tests.LoginTests")
local database = require("server.PADatabase")
local Server = require("server.server")
local GameModes = require("common.data.GameModes")
local Persistence = require("server.Persistence")
local server = Server(database, Persistence)
server:initializePlayerData("players.txt")
server:initializeLeaderboard(GameModes.getPreset("TWO_PLAYER_VS"), "leaderboard.csv")
local isPlayerTableEmpty = database:getPlayerRecordCount() == 0
if isPlayerTableEmpty then
server:importDatabase()
end
server:start()
while true do
server:update()
end