Línea de comandos

From Valve Developer Community
Jump to: navigation, search
English (en)español (es)
... Icon-Important.png
Info content.png
This page is being translated.

You can help by finishing the translation.

Also, please make sure the article tries to comply with the alternate languages guide.
No debe confundirse con Command Line Options (English).

Las herramientas del Source SDK de la línea de comandos son los que se operan por instrucciones escritas, en lugar de hacer clic en botones y navegar para archivos (en que GUIs son basadas. Este artículo va a dar un resumen breve sobre como usarlos.

Básicos

ícono de cmd.exe

Hay múltiples formas para acceder a la línea de comandos, pero la más sencilla es el símbolo del sistema. Para accederle en Windows Vista o después, buscar en el menú inicio para cmd. En Windows XP o antes, presione Win+R, teclee cmd, luego presione Enter.

Tip.pngTip:If you're in a hurry, commands can be executed directly from the start menu search box or the Run dialogue. But don't start doing that just yet.
Blank image.pngTodo: translate this. no sé como usar el condicional.
Tip.pngTip:Copiar y pegar son un poco extraños en CMD. Para pegar, haga clic derecho y elija la opción "menu". Para copiar, haga clic derecho y elija "Mark", después arrastre su ratón sobre el área que quiere y haga clic derecho otra vez.

Comandos

Ahora está preparado para entrar comandos. Teclee los comandos y presione Enter cuando termina. Aquí está un ejemplo que puede tratar:

"%sourcesdk%\bin\orangebox\bin\bspzip.exe"

Y aquí está que pasa:

  1. %sourcesdk% es un atajo a la carpeta del SDK, creado cuando el lanzador de SDK se lanza. Es mucho mas fácil que mecanografiar C:\Program Files\Steam\steamapps\<su nombre de cuenta de Steam>\sourcesdk\, y va a verlo mucho en este sitio.
    Tip.pngTip:Puede crear un atajo directamente a la carpeta "Tools". Busque como crear "environment variables" y apunte uno a "%sourcesdk%\bin\orangebox\bin\".
  2. Las comillas a los inicio y termino aseguran que el comando no se divide en dos por el espacio en él. ¿Qué espacio? Por supuesto, ¡lo que está en C:\Program Files\! Si no hay un espacio en la ruta, entonces las comillas no se necesitan.
    Warning.png Advertencia: No ponga parámetros (vea mas debajo) en comillas a menos que las necesitan. Definitivamente no póngalos en el mismo par como ello de la herramienta.
  3. El resto del comando es un ruta media (que debe ser familiar de Windows= a la herramienta BSPZIP English.
    Tip.pngTip:Extensiones de archivos .exe no se necesitan realmente, pero se incluyen aquí para claridad.

Parámetros

Ese comando ejecutará BSPZIP, pero todo el programa hará es imprimir los comandos que Ud. puede usar para hacerlo realmente hacer cosas.

Las comandas que cada herramienta acepta varia y se documentan en este sitio. Sin embargo, la forma de uso es el mismo cada vez:

<programa> <comando> <argument(os)> <comando> <argument(os)> ...

Vea como todo se separa por un espacio. Recuerde el consejo de comillas si es un problema. Asi:

"%sourcesdk%\bin\orangebox\bin\bspzip.exe" -extract mimapa.bsp contenidos.zip
  • -extract («extraiga») es un comando, que dice a BSPZIP que Ud. intenta a hacer. Comandos normalmente se ponen prefijo con un carácter -.
  • mimapa.bsp y contenidos.zip son argumentos, que dan detalles sobre como el comando debe hacer su tarea.
Note.pngNote:Un comando no siempre toma un argumento. También, a veces hay comandos que no tienen una palabra clave. Ud. sencillamente da un valor, típicamente un nombre de archivo, y la herramienta hacer su cosa.

Si examina el artículo de BSPZIP English you will see that the command above will take whatever files are embedded in the map and stick them in a .zip file somewhere on the hard drive. But where? The answer follows:

The Working Directory

You must pass a path to the location of every file or tool you want to work with. Except, that is, if it's in the 'working directory'. This is displayed before the cursor every time CMD is waiting for input, followed by a >, and will probably be pointing towards your user folder right now.

This means that if we type mymap.bsp or contents.zip as in the example above, BSPZIP will look for C:\Users\You\mymap.bsp and create C:\Users\You\contents.zip (assuming that's where your user folder is). That most likely isn't what you want, and to fix it you need to use the cd ('change directory') command before starting the tool itself:

cd "C:\Users\You\Documents\My mod\maps\"

That's a command followed by a parameter without a keyword, wrapped in quotes because of the space in My mod. Now BSPZIP will look for the two files in that folder, and hopefully find them there.

Alternatively you could type the full path for each file into the command, but since there are two such files in the command it's faster to cd first.

Tip.pngTip:It is also possible to specify relative paths. Use .\ for the current folder and work from there: e.g. .\maps\some_subfolder\. Use ..\ for the folder above the current one: e.g. ..\ to access My mod, ..\..\ to access Documents.

The working directory is not stored between sessions: it must be set every time you open the command prompt. Typing it in all the time gets old fast, which is why we have batch files.

Batch Files

Batch file icon

Commands can be written down in batch files that can then be executed at any time. To create one, save or rename any text file with the extension .cmd.

Aside from the fact that nothing is immediately executed, creating a batch file and typing straight into the command prompt are more or less the same. Type the command, hit Enter, type the next. There are only two things you should know:

Detener

The pause command will cause the CMD window that opens whenever the batch file is executed to wait for a keystroke to continue. This is vital for examining what's going on as otherwise it would close as soon as the operation had completed, which often takes only a split second. For instance:

cd "C:\Users\You\Documents\My mod\maps\"
"%sourcesdk%\bin\orangebox\bin\bspzip.exe" -extract mymap.bsp ..\contents.zip
pause

Substitución de nombres de archivos

In a similar manner to %sourcesdk%, the words %1 to %9 will be replaced by the path to any files that are dragged and dropped onto the batch file.

In the example being used by this article you'll have to get a little creative, since there are two values that need files but you only want to have to drag the map over. You could try something like this:

"%sourcesdk%\bin\orangebox\bin\bspzip.exe" -extract %1 %1_contents.zip

Which, if mymap.bsp is dropped onto it, will create mymap.bsp_contents.zip in the same folder. No need for cd this time, but a batch file like this won't work if it's just double-clicked on.

Véa también