Difference between revisions of "Compiling:Batch Files"

From Custom Map Makers Wiki
Jump to: navigation, search
Line 9: Line 9:
 
===The %1 variable===
 
===The %1 variable===
 
The %1 variable can be very usefull when making a batch file. Instead of a path to the file you want to work with you can simply use %1. This allowes you to work with the file that are droped on the batch file.
 
The %1 variable can be very usefull when making a batch file. Instead of a path to the file you want to work with you can simply use %1. This allowes you to work with the file that are droped on the batch file.
 +
 +
%1 refers to the file with it's drive, path, name and file extension.
 +
Eg: "C:\urtmapping\q3map_2.5.16_win32_x86\q3map2.exe"
 +
 +
%1 can be broken down to %~d1, %~p1 and %~n1 (there are more, referring to file extension, date and so but we don't need them here.)
 +
 +
%~d1 -Is the drive to the batch file or the file you drop on the batch file.
 +
Eg: "C:\"
 +
 +
%~p1 -Is the path to the batch file or the file you drop on the batch file.
 +
Eg: " urtmapping\q3map_2.5.16_win32_x86\"
 +
 +
%~n1 -Is the name to the batch file or the file you drop on the batch file.
 +
Eg: " q3map2"
 +
 +
By using this can we easily modify our compile.bat we find in our mapping folder.
 +
This is what my compile.bat looks like now:
 +
 +
<div class="BatchFilesEg" style="border:2px #999999 dotted; background-color:#dddddd; padding:10px; width:; left:50px;">
 +
    "C:\urtmapping\q3map_2.5.16_win32_x86\q3map2.exe" -meta -fs_basepath "C:\urtmapping" -fs_game q3ut4 "C:\urtmapping\q3ut4\maps\lighttest_a_a5.map"
 +
    "C:\urtmapping\q3map_2.5.16_win32_x86\q3map2.exe" -vis -fs_basepath "C:\urtmapping" "C:\urtmapping\q3ut4\maps\lighttest_a_a5.bsp"
 +
    "C:\urtmapping\q3map_2.5.16_win32_x86\q3map2.exe" -light -fs_basepath "C:\urtmapping" "C:\urtmapping\q3ut4\maps\lighttest_a_a5.bsp"
 +
</div>
 +
 +
 +
By using %~d1, %~p1 and %~n1 can we make a file that will compile the .map file dropped on it.
 +
 +
This is somewhat what it should look like:
 +
 +
<div class="BatchFilesEg" style="border:2px #999999 dotted; background-color:#dddddd; padding:10px; width:; left:50px;">
 +
    "C:\urtmapping\q3map_2.5.16_win32_x86\q3map2.exe" -meta -fs_basepath "C:\urtmapping" -fs_game q3ut4 "%~d1%~p1%~n1.map"
 +
    "C:\urtmapping\q3map_2.5.16_win32_x86\q3map2.exe" -vis -fs_basepath "C:\urtmapping" "%~d1%~p1%~n1.bsp"
 +
    "C:\urtmapping\q3map_2.5.16_win32_x86\q3map2.exe" -light -fs_basepath "C:\urtmapping" "%~d1%~p1%~n1.bsp"
 +
</div>
 +
  
 
===Example X===
 
===Example X===
 
Insted of writing the path to the image you want to open with mspaint you can simply put %1 insted. When you drag and drop a image on the batch file it will open the image with mspaint.
 
Insted of writing the path to the image you want to open with mspaint you can simply put %1 insted. When you drag and drop a image on the batch file it will open the image with mspaint.
<div id="BatchFilesEg" style="border:2px #999999 dotted; background-color:#dddddd; padding:10px; width:; left:50px;">
+
<div class="BatchFilesEg" style="border:2px #999999 dotted; background-color:#dddddd; padding:10px; width:; left:50px;">
 
mspaint %1
 
mspaint %1
 
</div>
 
</div>
  
 
[[Category:Compiling]]
 
[[Category:Compiling]]

Revision as of 10:40, 19 August 2011

Batch Files

About

Batch Files are files with one or more command line. Batch files are often used to add surface sounds and bot's. But they can manage the same as a frontend.

Commands

The %1 variable

The %1 variable can be very usefull when making a batch file. Instead of a path to the file you want to work with you can simply use %1. This allowes you to work with the file that are droped on the batch file.

%1 refers to the file with it's drive, path, name and file extension. Eg: "C:\urtmapping\q3map_2.5.16_win32_x86\q3map2.exe"

%1 can be broken down to %~d1, %~p1 and %~n1 (there are more, referring to file extension, date and so but we don't need them here.)

%~d1 -Is the drive to the batch file or the file you drop on the batch file. Eg: "C:\"

%~p1 -Is the path to the batch file or the file you drop on the batch file. Eg: " urtmapping\q3map_2.5.16_win32_x86\"

%~n1 -Is the name to the batch file or the file you drop on the batch file. Eg: " q3map2"

By using this can we easily modify our compile.bat we find in our mapping folder. This is what my compile.bat looks like now:

   "C:\urtmapping\q3map_2.5.16_win32_x86\q3map2.exe" -meta -fs_basepath "C:\urtmapping" -fs_game q3ut4 "C:\urtmapping\q3ut4\maps\lighttest_a_a5.map"
   "C:\urtmapping\q3map_2.5.16_win32_x86\q3map2.exe" -vis -fs_basepath "C:\urtmapping" "C:\urtmapping\q3ut4\maps\lighttest_a_a5.bsp"
   "C:\urtmapping\q3map_2.5.16_win32_x86\q3map2.exe" -light -fs_basepath "C:\urtmapping" "C:\urtmapping\q3ut4\maps\lighttest_a_a5.bsp"


By using %~d1, %~p1 and %~n1 can we make a file that will compile the .map file dropped on it.

This is somewhat what it should look like:

   "C:\urtmapping\q3map_2.5.16_win32_x86\q3map2.exe" -meta -fs_basepath "C:\urtmapping" -fs_game q3ut4 "%~d1%~p1%~n1.map"
   "C:\urtmapping\q3map_2.5.16_win32_x86\q3map2.exe" -vis -fs_basepath "C:\urtmapping" "%~d1%~p1%~n1.bsp"
   "C:\urtmapping\q3map_2.5.16_win32_x86\q3map2.exe" -light -fs_basepath "C:\urtmapping" "%~d1%~p1%~n1.bsp"


Example X

Insted of writing the path to the image you want to open with mspaint you can simply put %1 insted. When you drag and drop a image on the batch file it will open the image with mspaint.

mspaint %1