Difference between revisions of "Compiling:Batch Files"
(→About) |
|||
(9 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{WIP}} | ||
+ | |||
==Batch Files== | ==Batch Files== | ||
===About=== | ===About=== | ||
− | [http://en.wikipedia.org/wiki/Batch_file Batch Files] are files with one or more command line. Batch files are often used to add surface sounds and | + | [http://en.wikipedia.org/wiki/Batch_file Batch Files] are files with one or more command line. Batch files are often used to add surface sounds and bots. But they can manage the same as a frontend. |
+ | |||
+ | [[DagF_sample_batch]] | ||
==Commands== | ==Commands== | ||
===The %1 variable=== | ===The %1 variable=== | ||
− | The %1 variable can be very | + | The %1 variable can be very useful when making a batch file. Instead of a path to the file you want to work with you can simply use %1. This allows you to work with the file that are dropped 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. | ||
+ | |||
+ | "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=== | ===Example X=== | ||
− | + | Instead of writing the path to the image you want to open with mspaint you can simply put %1 instead. When you drag and drop a image on the batch file it will open the image with mspaint. | |
− | + | ||
− | + | "mspaint %1""" | |
− | + | ||
+ | ==Linux - Shell scripting== | ||
+ | |||
+ | Linux users can achieve something similar with shell scripting | ||
+ | |||
+ | #! /bin/bash | ||
+ | Q3MAP2='/path/2/q3map2' | ||
+ | BASEPATH='/path/2/.q3a' | ||
+ | |||
+ | ${Q3MAP2} -fs_basepath ${BASEPATH} -fs_game q3ut4 -meta ${1} | ||
+ | ${Q3MAP2} -fs_basepath ${BASEPATH} -fs_game q3ut4 -vis ${1%%.map}.bsp | ||
+ | ${Q3MAP2} -fs_basepath ${BASEPATH} -fs_game q3ut4 -light ${1%%.map}.bsp | ||
+ | |||
+ | The far more advanced (and probably easier way) is to use GNU/Make and [[Compiling:Makefiles|Makefiles]]. | ||
[[Category:Compiling]] | [[Category:Compiling]] |
Latest revision as of 14:58, 14 November 2012
This page is work in progress! |
Contents
Batch Files
About
Batch Files are files with one or more command line. Batch files are often used to add surface sounds and bots. But they can manage the same as a frontend.
Commands
The %1 variable
The %1 variable can be very useful when making a batch file. Instead of a path to the file you want to work with you can simply use %1. This allows you to work with the file that are dropped 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.
"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
Instead of writing the path to the image you want to open with mspaint you can simply put %1 instead. When you drag and drop a image on the batch file it will open the image with mspaint.
"mspaint %1"""
Linux - Shell scripting
Linux users can achieve something similar with shell scripting
#! /bin/bash Q3MAP2='/path/2/q3map2' BASEPATH='/path/2/.q3a' ${Q3MAP2} -fs_basepath ${BASEPATH} -fs_game q3ut4 -meta ${1} ${Q3MAP2} -fs_basepath ${BASEPATH} -fs_game q3ut4 -vis ${1%%.map}.bsp ${Q3MAP2} -fs_basepath ${BASEPATH} -fs_game q3ut4 -light ${1%%.map}.bsp
The far more advanced (and probably easier way) is to use GNU/Make and Makefiles.