This repository was archived by the owner on Nov 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
90 lines (77 loc) · 2.21 KB
/
main.lua
File metadata and controls
90 lines (77 loc) · 2.21 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
local shared = require("shared")
require("conf")
local function help()
local name = (love.filesystem.getSource()):match("(%w+)/?$")
print(string.format("%s [--help/server/client] [args]", name))
print("argument reference:")
print("\t--debug - runs in debug mode")
print()
love.event.quit(0)
end
local function handleError(error)
LS13.Logging.LogFatal("Unhandled error: %s %s", error, debug.traceback())
end
function love.load(args)
local runMode = "client"
if args[1] == "server" then
runMode = "server"
elseif args[1] == "--help" then
help()
return
end
if runMode == "client" then -- setup window
require("love.window")
require("love.keyboard")
local t = { modules = {}, audio = {}, window = {}, graphics = {} }
love.conf(t)
love.window.setMode(t.window.width, t.window.height, {
usedpiscale = t.window.usedpiscale,
fullscreen = t.window.fullscreen,
resizable = t.window.resizable,
displayindex = t.window.displayindex,
depth = t.window.depth,
vsync = t.window.vsync,
stencil = t.window.stencil,
msaa = t.window.msaa,
borderless = t.window.borderless,
minheight = t.window.minheight,
minwidth = t.window.minwidth,
})
_G.iconPath = t.window.icon
love.window.setTitle(t.window.title)
end
_G.LS13 = runMode == "server" and require("server") or require("client")
LS13.Info = require("info")
LS13.Role = runMode
LS13.LaunchArgs = args
local head = (love.filesystem.read(".git/refs/heads/master") or ""):gsub("\n", "")
local branch = (love.filesystem.read(".git/HEAD") or ""):gsub("^ref: .*/", ""):gsub("\n", "")
if branch == "" then branch = nil end
if head == "" then head = nil end
print(
string.format(
"%s/%s %s@%s RL %s %s w/ %s",
LS13.Info.Name,
LS13.Info.Ident,
LS13.Info.Version,
branch and "(" .. branch .. "/" .. head .. ")" or "off-git, release",
love._version,
love._version_codename,
_VERSION
)
)
xpcall(function()
shared.load()
LS13.load()
end, handleError)
end
function love.update(dt)
LS13.preframe() -- only for fps capping, for the love of god do not make it error
xpcall(function()
shared.update(dt)
LS13.update(dt)
end, handleError)
if SERVER then
LS13.postframe() -- only for fps capping on server
end
end