I have a list of mods in a launcher.bat server command line variable, separated by semicolon:
set Antistasi2=-mod=%ModPath%@CBA_A3;%ModPath%@Antistasi;%ModPath%@CAC_AE1.4;%ModPath%@AWR;%ModPath%@RealEngine;%ModPath%@ace;%ModPath%@EnhancedMovement;%ModPath%@EnhancedMovementRework;%ModPath%@MfHealAbort;%ModPath%@VET_Unflipping;%ModPath%@AdvancedRappelling;%ModPath%@AdvancedUrbanRappelling;%ModPath%@Blastcore`
And I have a simple mod checker (modchecker.bat which is called from within the launcher.bat, checks for existing folders with predefined mod name and types the missing mod folder names (mods):
if not exist %ModPath%"@CBA_A3" echo @CBA_A3 NOT FOUND
if not exist %ModPath%"@Antistasi" echo @Antistasi NOT FOUND
...
if not exist %ModPath%"@Blastcore" echo @Blastcore NOT FOUND
But there is more predefined mod folder names than the mods currently used in the command line.
What I would want to is not to use a predefined mod folder list, but instead use the command line to populate the mod checker and create if not exist %ModPath%"@modxxx" echo @modxxx NOT FOUND
line in the mod checker for each mod used in the command line.
To put it another way I would need to get the mod folder names from the command line array (-Mod=
inside an %Antistasi2%
variable (those would be: @CBA_A3, @Antistasi, etc. all the way to @Blastcore) and integrate them automatically into the mod checker so that the mod list from the command line auto populates the missing mod search in mod checker, so it does not have to be predefined manually.
And I have no clue how to do it. Please help.
Thanks in advance.
I'm assuming that the set {CBA_A3..Blastcore} will always be required and some extra modules may be specified, so
would add
extra
,something
andhello
to those standard items.I've also assumed that each module required is prefixed by
@
.I've established a dummy
modpath
for testing. You would need to change this.list
prepends the arguments from the command line to the standard list. Note that the leading space is important.I've remarked-out what happens should a module be missing. Just remove the
rem
to activate thepause
andgoto :eof
(which should cook dinner and terminate the batch if activated)Next. replace all double-spaces in
list
with single spaces.Next, replace all spaces in
list
with;%modpath%@
(note that the value ofmodpath
will be substituted) and assign toAntistasi2
Then remove the first character of
Antistasi2
and prefix it with-mod=
Note: Use
set "var=value"
for setting string values - this avoids problems caused by trailing spaces. Don't assign"
or a terminal backslash or Space. Build pathnames from the elements - counterintuitively, it is likely to make the process easier. If the syntaxset var="value"
is used, then the quotes become part of the value assigned.If you remove the
\
as advised, you would need to insert it before the@
in theif not exist
statement and thecall set
statement.