@@ -199,6 +199,30 @@ function WaitForInput
199
199
}
200
200
}
201
201
202
+ function ReadConfigLine ($line , $name )
203
+ {
204
+ if ($line.StartsWith ($name ))
205
+ {
206
+ $prefix = $name + ' ='
207
+ [Environment ]::SetEnvironmentVariable($name , $line.Replace ($prefix , ' ' ).Replace(' "' , ' ' ))
208
+ }
209
+ }
210
+
211
+ function ParseConfigFile ($fileName )
212
+ {
213
+ $names = @ (" MOD_ID" , " INCLUDE_DEFAULT_MODS" , " ENGINE_VERSION" , " AUTOMATIC_ENGINE_MANAGEMENT" , " AUTOMATIC_ENGINE_SOURCE" ,
214
+ " AUTOMATIC_ENGINE_EXTRACT_DIRECTORY" , " AUTOMATIC_ENGINE_TEMP_ARCHIVE_NAME" , " ENGINE_DIRECTORY" )
215
+
216
+ $reader = [System.IO.File ]::OpenText($fileName )
217
+ while ($null -ne ($line = $reader.ReadLine ()))
218
+ {
219
+ foreach ($name in $names )
220
+ {
221
+ ReadConfigLine $line $name
222
+ }
223
+ }
224
+ }
225
+
202
226
# ##############################################################
203
227
# ########################### Main #############################
204
228
# ##############################################################
@@ -225,51 +249,15 @@ else
225
249
226
250
# Load the environment variables from the config file
227
251
# and get the mod ID from the local environment variable
228
- $reader = [System.IO.File ]::OpenText(" mod.config" )
229
- while ($null -ne ($line = $reader.ReadLine ()))
230
- {
231
- if ($line.StartsWith (" MOD_ID" ))
232
- {
233
- $env: MOD_ID = $line.Replace (' MOD_ID=' , ' ' ).Replace(' "' , ' ' )
234
- $modID = $env: MOD_ID
235
- }
236
-
237
- if ($line.StartsWith (" INCLUDE_DEFAULT_MODS" ))
238
- {
239
- $env: INCLUDE_DEFAULT_MODS = $line.Replace (' INCLUDE_DEFAULT_MODS=' , ' ' ).Replace(' "' , ' ' )
240
- }
252
+ ParseConfigFile " mod.config"
241
253
242
- if ($line.StartsWith (" ENGINE_VERSION" ))
243
- {
244
- $env: ENGINE_VERSION = $line.Replace (' ENGINE_VERSION=' , ' ' ).Replace(' "' , ' ' )
245
- }
246
-
247
- if ($line.StartsWith (" AUTOMATIC_ENGINE_MANAGEMENT" ))
248
- {
249
- $env: AUTOMATIC_ENGINE_MANAGEMENT = $line.Replace (' AUTOMATIC_ENGINE_MANAGEMENT=' , ' ' ).Replace(' "' , ' ' )
250
- }
251
-
252
- if ($line.StartsWith (" AUTOMATIC_ENGINE_SOURCE" ))
253
- {
254
- $env: AUTOMATIC_ENGINE_SOURCE = $line.Replace (' AUTOMATIC_ENGINE_SOURCE=' , ' ' ).Replace(' "' , ' ' )
255
- }
256
-
257
- if ($line.StartsWith (" AUTOMATIC_ENGINE_EXTRACT_DIRECTORY" ))
258
- {
259
- $env: AUTOMATIC_ENGINE_EXTRACT_DIRECTORY = $line.Replace (' AUTOMATIC_ENGINE_EXTRACT_DIRECTORY=' , ' ' ).Replace(' "' , ' ' )
260
- }
261
-
262
- if ($line.StartsWith (" AUTOMATIC_ENGINE_TEMP_ARCHIVE_NAME" ))
263
- {
264
- $env: AUTOMATIC_ENGINE_TEMP_ARCHIVE_NAME = $line.Replace (' AUTOMATIC_ENGINE_TEMP_ARCHIVE_NAME=' , ' ' ).Replace(' "' , ' ' )
265
- }
266
-
267
- if ($line.StartsWith (" ENGINE_DIRECTORY" ))
268
- {
269
- $env: ENGINE_DIRECTORY = $line.Replace (' ENGINE_DIRECTORY=' , ' ' ).Replace(' "' , ' ' )
270
- }
254
+ if (Test-Path " user.config" )
255
+ {
256
+ ParseConfigFile " user.config"
271
257
}
272
258
259
+ $modID = $env: MOD_ID
260
+
273
261
$env: MOD_SEARCH_PATHS = (Get-Item - Path " .\" - Verbose).FullName + " \mods"
274
262
if ($env: INCLUDE_DEFAULT_MODS -eq " True" )
275
263
{
@@ -326,7 +314,7 @@ if ($command -eq "all" -or $command -eq "clean")
326
314
$dlPath = Join-Path $pwd (Split-Path - leaf $env: AUTOMATIC_ENGINE_EXTRACT_DIRECTORY )
327
315
$dlPath = Join-Path $dlPath (Split-Path - leaf $env: AUTOMATIC_ENGINE_TEMP_ARCHIVE_NAME )
328
316
329
- $client = new-object System.Net.WebClient
317
+ $client = new-object System.Net.WebClient
330
318
$client.DownloadFile ($url , $dlPath )
331
319
332
320
Add-Type - assembly " system.io.compression.filesystem"
0 commit comments