-
Notifications
You must be signed in to change notification settings - Fork 40
/
conf.lua
253 lines (226 loc) · 5.31 KB
/
conf.lua
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
--------------------------------
-- Config file for trAInsported.
--------------------------------
-- by Germanunkol
-- Options:
-- -d
--
function os.capture(cmd, raw)
local f = assert(io.popen(cmd, 'r'))
local s = assert(f:read('*a'))
f:close()
if raw then return s end
s = string.gsub(s, '^%s+', '')
s = string.gsub(s, '%s+$', '')
s = string.gsub(s, '[\n\r]+', ' ')
return s
end
function seperateStrings(str)
tbl = {}
index = 1
if str:sub(#str,#str) ~= "," then -- gmatch will not capture a substring unless there's a comma following
str = str .. ","
end
for val in string.gmatch(str, ".-,") do
tbl[index] = val:sub(1,#val-1)
pos = #val+1
index = index + 1
end
return tbl
end
-- Check if game this is running in dedicated server mode:
for k, a in pairs(arg) do
if a == "-s" or a == "--dedicated" or a == "--server" then
DEDICATED = true
arg[k] = nil
break
end
end
-- Check if user has given a port number:
for k, a in pairs(arg) do
if a == "-p" or a == "--port" then
INVALID_PORT = true
if type(k) == "number" then
if arg[k+1] then
p = tonumber(arg[k+1])
if p >= 0 and p <= 65535 then
CL_PORT = p
INVALID_PORT = false
end
arg[k+1] = nil
arg[k] = nil
end
end
break
end
end
for k, a in pairs(arg) do
if a == "--mapsize" then
INVALID_MAPSIZE = true
if type(k) == "number" then
if arg[k+1] then
s = tonumber(arg[k+1])
if s >= 5 and s <= 100 then
MAP_SIZE = s
INVALID_MAPSIZE = false
end
arg[k+1] = nil
arg[k] = nil
end
end
break
end
end
for k, a in pairs(arg) do
if a == "--directory" or a == "-d" then
INVALID_DIRECTORY = true
if type(k) == "number" then
if arg[k+1] then
if os.capture("uname") == "Linux" then
CL_DIRECTORY = arg[k+1]
INVALID_DIRECTORY = false;
arg[k+1] = nil
arg[k] = nil
end
end
end
break
end
end
for k, a in pairs(arg) do
if a == "--chart" then
INVALID_CHART_DIRECTORY = true
if type(k) == "number" then
if arg[k+1] then
CL_CHART_DIRECTORY = arg[k+1]
INVALID_CHART_DIRECTORY = false;
arg[k+1] = nil
arg[k] = nil
end
end
break
end
end
for k, a in pairs(arg) do
if a == "--match_time" or a == "-m" then
INVALID_MATCH_TIME = true
if type(k) == "number" then
if arg[k+1] then
t = tonumber(arg[k+1])
if t >= 10 then
CL_ROUND_TIME = t
INVALID_MATCH_TIME = false
end
arg[k+1] = nil
arg[k] = nil
end
end
break
end
end
for k, a in pairs(arg) do
if a == "--cooldown" or a == "-c" then
INVALID_DELAY_TIME = true
if type(k) == "number" then
if arg[k+1] then
t = tonumber(arg[k+1])
if t >= 0 then
CL_TIME_BETWEEN_MATCHES = t
INVALID_DELAY_TIME = false
end
arg[k+1] = nil
arg[k] = nil
end
end
break
end
end
for k, a in pairs(arg) do
if a == "--host" or a == "-h" or a == "--ip" then
INVALID_IP = true
if type(k) == "number" then
if arg[k+1] then
ip = arg[k+1]
CL_SERVER_IP = ip
INVALID_IP = false
arg[k+1] = nil
arg[k] = nil
end
end
break
end
end
for k, a in pairs(arg) do
if a == "--mysql" then
INVALID_MYSQL = true
if type(k) == "number" then
if arg[k+1] then
login = seperateStrings(arg[k+1])
if login[1] and login[2] then
CL_MYSQL_NAME = login[1]
CL_MYSQL_PASS = login[2]
CL_MYSQL_HOST = login[3] or "localhost" -- could be nil!
CL_MYSQL_PORT = login[4] -- could be nil!
INVALID_MYSQL = false
end
arg[k+1] = nil
arg[k] = nil
end
end
break
end
end
for k, a in pairs(arg) do
if a == "--mysqlDB" then
INVALID_MYSQL_DATABASE = true
if type(k) == "number" then
if arg[k+1] then
ip = arg[k+1]
CL_MYSQL_DATABASE = ip
INVALID_MYSQL_DATABASE = false
arg[k+1] = nil
arg[k] = nil
end
end
break
end
end
for k, a in pairs(arg) do
if a == "--render" then
CL_FORCE_RENDER = true
arg[k] = nil
break
end
end
if not DEDICATED then
love.conf = function(t)
--t.screen.width = 800
--t.screen.height = 600
--t.screen.fullscreen = false
t.title = "trAInsported" -- The title of the window the game is in (string)
t.version = "0.9.1"
t.author = "Germanunkol" -- The author of the game (string)
t.url = "http://www.indiedb.com/members/germanunkol"
end
else
love.conf = function(t)
--t.screen.width = 50
--t.screen.height = 25
--t.screen.fullscreen = false
t.title = "trAInsported" -- The title of the window the game is in (string)
t.version = "0.9.1"
t.author = "Germanunkol" -- The author of the game (string)
t.url = "http://www.indiedb.com/members/germanunkol"
t.modules.joystick = false -- Enable the joystick module (boolean)
t.modules.audio = false -- Enable the audio module (boolean)
t.modules.keyboard = true -- Enable the keyboard module (boolean)
t.modules.event = true -- Enable the event module (boolean)
t.modules.image = false -- Enable the image module (boolean)
t.modules.window = false -- Enable the physics module (boolean)
t.modules.graphics = false -- Enable the graphics module (boolean)
t.modules.timer = true -- Enable the timer module (boolean)
t.modules.mouse = false -- Enable the mouse module (boolean)
t.modules.sound = false -- Enable the sound module (boolean)
t.modules.physics = false -- Enable the physics module (boolean)
end
end