Not enough ratings
Testing quickly and effectively with the command prompt
By Kamek
Harnessing the power of the command prompt for testing POSTAL 2 custom content.
The command prompt can be a scary beast, but it's also a very powerful one. While developing the source code and UnrealScript, I almost exclusively use the command prompt for testing my changes. This guide will show you how to get started and list some commonly-used command line options.
Creating a cmd.exe shortcut
If you've followed my guide, Getting Started With POSTed, then you've already installed the POSTed Development Kit and set up a shortcut to the editor folder on the desktop. Now we need a command prompt shortcut.

You can create your new shortcut on the desktop too, or simply stuff it into the System folder or the POSTAL2Editor folder itself. Right-click on the desktop or the Explorer window of the folder you wish to create the shortcut in, select New, then select Shortcut.

When prompted for the location of the item, enter "cmd.exe" and press Enter. Accept the default for any further prompts, and you will have a cmd shortcut! However, if you attempt to open this shortcut, you'll find that it opens up by default to the Windows directory. This isn't what we want at all, so close that out, then right-click your cmd shortcut and hit Properties.

We want to change the "Start in" value so it doesn't start in the Windows folder. Simply delete the contents of that field, so it appears blank. If it's blank, it will use the folder you launched in as the working folder. Hit OK to save changes, and now try launching your new shortcut.

Now you're in your System directory, but the path name is so damn long that if you start typing in a command it's going to wrap around the edge, making it difficult to read. What to do now?

Thankfully, you can redesign the way the Windows command prompt looks, using the Prompt command. For example, if you do this...

prompt ]'ll find that your command prompt now looks like this:


This, however, is a bit too much. It's useful to know what your working directory is. So what we'll do is use the Prompt variables to craft us a command prompt that will work for us. If you type:

prompt /?

you'll get a list of variables you can use in the Prompt command. We want to print the working directory, then advance to the next line, and then print out a bracket or a greater-than sign to use as our prompt. This way the command we type won't go off the side of the window 90% of the time.

prompt $p$_]

This will give us something that looks like this:

D:\SteamLibrary\steamapps\common\POSTAL2Editor\System ]_

If you put a space after the bracket, then your cursor will be spaced out from the bracket accordingly. Feel free to use the prompt variables to "dress up" your prompt to your liking. Here's what I used:

prompt [$t] $p$_] [19:07:04.93] D:\SteamLibrary\steamapps\common\POSTAL2Editor\System ] _

You can also use ANSI escape sequences to do fancy things like colorizing your prompt, but I'll leave that as an exercise to the reader.

Once you have a prompt to your liking, you'll need to set your cmd.exe shortcut so that it uses your new prompt every time, otherwise it will revert to the default Windows prompt. What you're going to do is right-click and edit your cmd.exe shortcut, add the /k switch, and then put your prompt command. The /k switch tells cmd.exe to execute the following command, and then stay open for further commands. When you get done, your cmd.exe shortcut should look something like this:

And give you a resulting command window like this:

Congratulations! Now, on to actual POSTAL 2 related stuff!
Testing maps, gametypes, P2GameMods, and using the real-time log
Okay, so now that you have a command prompt, it's time to make use of it. Pretend you're me trying to debug an issue in the Apocalypse Weekend game that occurs in the Gayfish map (the first time the Dude goes to the publisher complex). Type in this command:

postal2 gayfish?Game=GameTypes.AWGameSPFinal -log

If you typed it correctly, you should see a log window pop up instead of the splash screen, and then you'll land in the publisher's office. Chances are, you're also in fullscreen mode. Press alt-enter to get out of fullscreen mode, then hit Escape to bring up the menu. From here you can move the game window and log window to your liking. If you have a second monitor, like me, you can drag the log screen to your second monitor and make it huge, then you can switch back to the game and fullscreen it or just make it bigger.

Anyway, let's take a look at that command line some. There are four major parts of that last command.

  • postal2 tells Windows to launch the POSTAL 2 executable.
  • gayfish tells POSTAL 2 to skip the usual startup sequence and start immediately on the Gayfish map.
  • ?Game= tells POSTAL 2 to start with a specific GameInfo, in this case, GameTypes.AWGameSPFinal, which is the Apocalypse Weekend game. You could launch Gayfish without this and everything would appear fine, but you'd actually be in the A Week In Paradise game mode, with a map of Paradise and possibly other items you're not supposed to have. If you're testing your own custom GameInfo, then you're going to use that instead (?Game=MyPackage.MyAwesomeGameInfo).
  • -log causes that fancy log window to pop up instead of the splash screen. Be warned that this can slow down the game quite a bit if you have a lot of debug logging going on, but it can be a highly useful tool to view log information in real time. Everything in this window is also output to postal2.log, so if you miss something you can go back and check.

If you're testing a P2GameMod as well, you can add that to the command line like so:

postal2 mapname?Mutator=MyPackage.MySweetP2GameMod

?Mutator= tells POSTAL 2 to launch the game using the specified mutator (P2GameMods are subclasses of Mutator).

You can combine ?GameType and ?Mutator if necessary:

postal2 mapname?GameType=MyPackage.MyAwesomeGameInfo?Mutator=MyPackage.MySweetP2GameMod
Other useful command line options
Here are some more options you'll find useful for testing. Options that begin with a question mark (?) form the Browse URL, which is how the engine loads a map, game type, and so forth. For example, in postal2 suburbs-3?Game=GameTypes.GameSinglePlayer -log, the Browse URL is "suburbs-3?Game=GameTypes.GameSinglePlayer". Options that begin with a dash (-) are parameters (the "-log" above is a parameter). Don't get these two mixed up -- the URL must be all crammed together with no spaces, and parameters must be separated by spaces.

This is not a comprehensive list -- see my guide on command line options for a complete list.

  • ?Enhanced=1 forces the game to start in the Enhanced Game mode. This can be useful for testing special Enhanced Game effects of your custom weapons.
  • ?SetDay=n sets the day number. 1 is Monday, 2 is Tuesday, and so on. It does not complete errands for you or assign hate groups, so RWS employees will still bother you to go see Vince, protestors won't hate you, and so on. Everything else behaves as though it is the correct day.
  • -windowed starts the game in windowed mode.
  • -nosteam starts the game in Non-Steam Mode. The Steam overlay will not show up and Workshop items will not be downloaded or updated.
An important caveat
It is important to note that, by default, testing on the command line will tell Steam that you are in the POSTed app. This means that it will not download any Workshop items you are subscribed to in the base game. If you need to test your content against existing Workshop items, you will need to manually change the Steam AppID contained in the file steam_appid.txt.

Open up the file steam_appid.txt with your text editor, and change the number within to POSTAL 2's AppID, 223470. Now, launch Postal2 from the command line, and all your subscribed Workshop items will download. Once that has completed, you can invoke them from the command line, provided you know the name of the P2GameMod or GameInfo (you can find them in the item's INT file, in WorkshopContent)

Changing this file will not affect the editor, unless you launch it outside of Steam, from the command prompt or Explorer. Be advised that any items you publish this way will show up on the Workshop properly, but cannot be revised later using the normal editor link in Steam - you'll have to launch it from the command line under POSTAL 2's AppID.

To go back to normal, delete steam_appid.txt and verify your cache, or simply change the number back to POSTed's AppID, 298860.
< >
Puffy the destroyer Jan 14, 2017 @ 7:07pm 
is this optional or REQUIRED / neccesary? i may have fucked up