Portal 2/Creating a mod

__NOTOC__
== Introduction ==
This tutorial is how to make a mod, with custom chapters, backgrounds, vgui, music for backgrounds, and more.
== Getting Started ==
=== Creating your first mod ===
first steps is to create a folder for your mod in and rename it to the name of your mod. Open the folder and create two subfolders: "cfg" and "maps".
Open the "maps" folder and create a folder called "soundcache" inside it. Copy the file called "_master.cache" from and paste it to .
=== Creating gameinfo.txt ===
Next step is creating the most important file, gameinfo.txt. Create a text file named gameinfo.txt and open it up and copy the following code:
"GameInfo"
{
 game "Your Mod's Name"
 GameData "portal2.fgd"
 FileSystem
 {
 SteamAppId 620 // Portal 2 has ID 620
 SearchPaths
 {
 Game |gameinfo_path|.
 Game portal2_dlc2
 Game portal2_dlc1
 Game portal2
 }
 }
}
Remove the search path, UNLESS your mod is going to have Co-Op functionality.
=== Customise core menu funtions ===
Use a program like to open and copy the file called to or create a folder and name it "pak01_dir" and place it anywhere on your pc, easy to reach is by having on desktop and make folders . Edit it (See Below), then pack it into a new VPK using or , and place it in your mods folder.
==== Removing the Co-Op button ====
This part is optional, unless your mod is NOT going to have Co-Op functionality.
Open the file with a text editor.
When you have the file open, you'll see something like this:
	"BtnCoOp"
	{
		"ControlName"				"BaseModHybridButton"
		"fieldName"					"BtnCoOp"
		"xpos"						"88"		[$GAMECONSOLE && ($GAMECONSOLEWIDE && !$ANAMORPHIC)]
		"xpos"						"63"		[$GAMECONSOLE && (!$GAMECONSOLEWIDE || $ANAMORPHIC)]	
		"xpos"						"88"		[!$GAMECONSOLE && $WIN32WIDE]
		"xpos"						"63"		[!$GAMECONSOLE && !$WIN32WIDE]	
		"ypos"						"250"		[$GAMECONSOLE] 
		"ypos"						"228"		[!$GAMECONSOLE] 	
		"wide"						"280"
		"tall"						"20"
		"autoResize"				"1"
		"pinCorner"					"0"
		"visible"					"1"
		"enabled"					"1"
		"tabPosition"				"0"
		"navUp"						"BtnQuit"					[$GAMECONSOLE]
		"navUp"						"BtnPlaySolo"				[!$GAMECONSOLE]
		"navDown"					"BtnCommunity"
		"labelText"					"#PORTAL2_MainMenu_CoOp"
		"style"						"MainMenuButton"
		"command"					"CoopPlay"
		"ActivationType"			"1"
		"FocusDisabledBorderSize"	"1"
	}
This is the code that describes the Co-Op button, position on the screen, name of the button, what to do when clicked, and which buttons come next and before it when using the arrow keys. You can delete all of it.
Next thing is to find the "navDown" on "BtnPlaySolo":
Once you have found it replace it with:
"navDown"					"Options"
Also find "navUp":
Once you have found it, replace it with:
"navUp"					"BtnPlaySolo"
Now, once you compiled it into a vpk file and start the game, you'll see gap between single player and community buttons.
Lets fix that by finding the "ypos" on "BtnCommunity":
it should look like this:
"ypos"						"258"	[!$GAMECONSOLE] 
replace it with the "ypos" from the "BtnCoOp":
"ypos"						"228"	[!$GAMECONSOLE] 
Do this to all buttons except the single player button, if you dont want the buttons to be in the middle then replace the "ypos" from "BtnPlaySolo" with "228".
Then pack it into a new VPK using and place it in your mods folder.
Thats all for removing the Coop button, this also applies to all buttons in the file.
Here is the premade file without the Coop button and no gap:
"Resource/UI/MainMenu.res"
{
	"MainMenu"
	{
		"ControlName"				"Frame"
		"fieldName"					"MainMenu"
		"xpos"						"0"
		"ypos"						"0"
		"wide"						"f0"
		"tall"						"f0"
		"autoResize"				"0"
		"pinCorner"					"0"
		"visible"					"1"
		"enabled"					"1"
		"tabPosition"				"0"
		"PaintBackgroundType"		"0"
	}
						
	// Single player
	"BtnPlaySolo"
	{
		"ControlName"				"BaseModHybridButton"
		"fieldName"					"BtnPlaySolo"
		"xpos"						"88"		[$GAMECONSOLE && ($GAMECONSOLEWIDE && !$ANAMORPHIC)]
		"xpos"						"63"		[$GAMECONSOLE && (!$GAMECONSOLEWIDE || $ANAMORPHIC)]	
		"xpos"						"88"		[!$GAMECONSOLE && $WIN32WIDE]
		"xpos"						"63"		[!$GAMECONSOLE && !$WIN32WIDE]	
		"ypos"						"220"		[$GAMECONSOLE] 
		"ypos"						"198"		[!$GAMECONSOLE] 	
		"wide"						"280"
		"tall"						"20"
		"autoResize"				"1"
		"pinCorner"					"0"
		"visible"					"1"
		"enabled"					"1"
		"tabPosition"				"0"
		"navUp"						"BtnQuit"	[$GAMECONSOLE]
		"navUp"						"BtnEconUI"		[!$GAMECONSOLE]
		"navDown"					"BtnCoOp"
		"labelText"					"#PORTAL2_MainMenu_Solo"
		"style"						"MainMenuButton"
		"command"					"SoloPlay"
		"ActivationType"			"1"
		"FocusDisabledBorderSize"	"1"
	}
	// Community Maps
	"BtnCommunity" [!$GAMECONSOLE]
	{
		"ControlName"				"BaseModHybridButton"
		"fieldName"					"BtnCommunity"
		"xpos"						"88"	[$GAMECONSOLE && ($GAMECONSOLEWIDE && !$ANAMORPHIC)]
		"xpos"						"63"	[$GAMECONSOLE && (!$GAMECONSOLEWIDE || $ANAMORPHIC)]	
		"xpos"						"88"	[!$GAMECONSOLE && $WIN32WIDE]
		"xpos"						"63"	[!$GAMECONSOLE && !$WIN32WIDE]	
		"ypos"						"280"	[$GAMECONSOLE] 
		"ypos"						"228"	[!$GAMECONSOLE] 	
		"wide"						"280"
		"tall"						"20"
		"autoResize"				"1"
		"pinCorner"					"0"
		"visible"					"1"
		"enabled"					"1"
		"tabPosition"				"0"
		"navUp"						"BtnOptions"	[$GAMECONSOLE]
		"navUp"						"BtnCoOp"		[!$GAMECONSOLE]
		"navDown"					"BtnOptions"
		"labelText"					"#PORTAL2_MainMenu_Community"
		"style"						"MainMenuButton"
		"command"					"CreateChambers"
		"ActivationType"			"1"
		"FocusDisabledBorderSize"	"1"
	}
	
	"BtnOptions"
	{
		"ControlName"				"BaseModHybridButton"
		"fieldName"					"BtnOptions"
		"xpos"						"88"	[$GAMECONSOLE && ($GAMECONSOLEWIDE && !$ANAMORPHIC)]
		"xpos"						"63"	[$GAMECONSOLE && (!$GAMECONSOLEWIDE || $ANAMORPHIC)]	
		"xpos"						"88"	[!$GAMECONSOLE && $WIN32WIDE]
		"xpos"						"63"	[!$GAMECONSOLE && !$WIN32WIDE]	
		"ypos"						"310"	[$GAMECONSOLE] 
		"ypos"						"258"	[!$GAMECONSOLE] 
		"wide"						"280"
		"tall"						"20"
		"autoResize"				"1"
		"pinCorner"					"0"
		"visible"					"1"
		"enabled"					"1"
		"tabPosition"				"0"
		"navUp"						"BtnCoOp"			[$GAMECONSOLE]
		"navUp"						"BtnCommunity"	[!$GAMECONSOLE]
		"navDown"					"BtnPlaySolo"		[$GAMECONSOLE]
		"navDown"					"BtnExtras"			[!$GAMECONSOLE]
		"labelText"					"#PORTAL2_MainMenu_Options"
		"style"						"MainMenuButton"
		"command"					"Options"
		"ActivationType"			"1"
	}
	
	"BtnExtras" [!$GAMECONSOLE]
	{
		"ControlName"				"BaseModHybridButton"
		"fieldName"					"BtnExtras"
		"xpos"						"88"	[$GAMECONSOLE && ($GAMECONSOLEWIDE && !$ANAMORPHIC)]
		"xpos"						"63"	[$GAMECONSOLE && (!$GAMECONSOLEWIDE || $ANAMORPHIC)]	
		"xpos"						"88"	[!$GAMECONSOLE && $WIN32WIDE]
		"xpos"						"63"	[!$GAMECONSOLE && !$WIN32WIDE]	
		"ypos"						"340"	[$GAMECONSOLE] 
		"ypos"						"288"	[!$GAMECONSOLE] 
		"wide"						"280"
		"tall"						"20"
		"autoResize"				"1"
		"pinCorner"					"0"
		"visible"					"1"
		"enabled"					"1"
		"tabPosition"				"0"
		"navUp"						"BtnOptions"
		"navDown"					"BtnQuit"
		"labelText"					"#L4D360UI_MainMenu_Extras"
		"style"						"MainMenuButton"
		"command"					"Extras"
		"ActivationType"			"1"
	}
	"BtnQuit" [!$GAMECONSOLE]
	{
		"ControlName"				"BaseModHybridButton"
		"fieldName"					"BtnQuit"
		"xpos"						"88"	[$WIN32WIDE]
		"xpos"						"63"	[!$WIN32WIDE]	
		"ypos"						"318"
		"wide"						"280"
		"tall"						"20"
		"autoResize"				"1"
		"pinCorner"					"0"
		"visible"					"1"
		"enabled"					"1"
		"tabPosition"				"0"
		"navUp"						"BtnExtras"
		"navDown"					"BtnEconUI"
		"labelText"					"#PORTAL2_MainMenu_Quit"
		"style"						"MainMenuButton"
		"command"					"QuitGame"
		"ActivationType"			"1"
	}
	"BtnEconUI" [!$GAMECONSOLE]
	{
		"ControlName"				"BaseModHybridButton"
		"fieldName"					"BtnEconUI"
		"xpos"						"88"	[$WIN32WIDE]
		"xpos"						"63"	[!$WIN32WIDE]	
		"ypos"						"348"
		"wide"						"280"
		"tall"						"20"
		"autoResize"				"1"
		"pinCorner"					"0"
		"visible"					"1"
		"enabled"					"1"
		"tabPosition"				"0"
		"navUp"						"BtnQuit"
		"navDown"					"BtnPlaySolo"
		"labelText"					"#PORTAL2_MainMenu_Econ"
		"style"						"BitmapButton"
		"command"					"EconUI"
		"ActivationType"			"1"
		"bitmap_enabled"			"vgui/store/store_button"
		"bitmap_focus"				"vgui/store/store_button_focus_anim"
	}
	"PnlCloudPic"
	{
		"ControlName"			"ImagePanel"
		"fieldName"				"PnlCloudPic"
		"xpos"					"310"
		"ypos"					"288"
		"wide"					"50"
		"tall"					"50"
		"visible"				"0"
		"enabled"				"1"
		"tabPosition"			"0"
		"scaleImage"			"1"
		"image"					"resource/icon_cloud_small"
	}
}
=== Restart Steam ===
Restart Steam. If it all worked, your mod should be listed and working. Congratulations!
== Advanced ==
This part is going to guide you how to create custom images, button chapters, audio for backgrounds, and more.
=== Fixing text on main menu ===
Some parts of the main menu, there are missing text or text looking something like this: #P2Controller_PortalBlue.
To fix that, go to and copy portal2_english.txt to and rename the file to <mod name>_english.txt. (identical with _german, _greek, etc.)
Now lets replace some text, open (your mod)_engish.txt, and go to the line 453. You should find EXTRAS, replace that with something like NEW GAME.
The next part is the quit confirmation dialog. Find the lines 1687 and 1688. You should find Portal 2, replace that with the name of your mod. If you want to, you can also replace Are you sure you want to quit? with something like But there's still science to do!.
And you are done. open your Portal 2 mod and the text should be fixed and you should have custom text.
=== Creating a button for custom chapters ===
This part is almost identical to the above.
First step is to Find the "BtnPlaySolo" (directly at the top) and rename it to "BtnExtras":
Once you did that, find the "command":
"command"					"SoloPlay"
Replace it with:
"command"					"Extras"
This will make it jump into the Extras menu, allowing us to customise the chapter list.
If you did the Fixing text on main menu, then this part is optional, find the "labelText":
"labelText"					"#PORTAL2_MainMenu_Solo"
and replace it with your desire. For example:
"labelText"					"Play Portal 2: The Ruins"
Dont forget to remove the actual "Extras" button!
Next step is to replace the "navUp/Down" with corresponding button names.
For replace the with .
For replace the with .
If you dont have the BtnCoOp you can replace the "navDown" on the single player button or the Extras button with 
This also applies to all buttons in the file.
=== Create functioning chapter buttons ===
For this, we have to use the Extras menu as the single player menu, the reason why we used the Extras command instead of the SoloPlay command is because the SoloPlay only shows Portal 2 chapters instead of the custom chapters.
Here, you can have as many or as little chapters as you like. You'll need to create a 'scripts' folder for this task. 
Inside this folder, create an extras text file. 
While we're in the scripts folder, go to and copy the game_sounds_manifest text file over to your mod's scripts folder. 
Back to the extras text file, copy and paste the following code:
"Extras"
{
 "chapter1"
 {
 "title" "Chapter 1"
 "subtitle" "The Wake Up"
 "command" "map sp_a1_00" //map name to start the first chapter
 "pic" "vgui/chapters/chapter1"
 }
	// You can copy as many as you want
 "chapter2"
 {
 "title" "Chapter 2"
 "subtitle" "The Portal Gun"
 "command" "map sp_a2_01" //map name to start the second chapter and so on
 "pic" "vgui/chapters/chapter2"
 }
}
=== Creating your own images ===
For the logo/background/chapters you will need an image editor, something like: , , etc.
This guide will use for creating logos/backgrounds/chapters. There are plug-ins to export it as a .vtf file, but in this guide we will use 
==== Logo ====
Create a new image file with a resolution of 512x128. Then choose 'Transparency' under Advanced. This allows you to admire your logo in all its glory without a visible background layer. The rest is up to you and your imagination!
After creating your logo export it as a .png or .tga, then create a .vmt file and name it "portal2logo.vmt" or open and press on new. (save it somewhere on your desktop)
and copy this code:
UnlitGeneric
{
$basetexture "vgui/portal2logo" 
$translucent 1
$vertexcolor 1
$vertexalpha 1
$ignorez 1
$additive 0
$no_fullbright 1
$SHADERSRGBREAD360 1
}
Now lets create the .vtf file.
Open and click on import, on Normal Format, change it to BGRA8888 and on Alpha format to DXT 1. Set the size to 512x128, and then press ok.
When you have done that you will see the background is black, to fix that go to View and enable mask (shortcut Ctrl+M).
On flags check No Mipmap and No Level Of Detail, by default the Eight bit Alpha should be checked, if not, the import it again.
Once you have done all of that, click on Save As and name it to portal2logo.vtf.
Now place both files in your pak01_dir in 
Pack it again and open the game, if the logo is there, Congratulations! you created your logo!
==== Icon ====
For the icon of your mod to show, there are two places it can be displayed: In your steam library and on your desktop.
To make your icon you will need an image editor, something like: , , .
To start open an image editor and create a new file with the dimensions 256x256 pixels. Then save your image as a targa file (.tga) in a folder (For example ) and name it icon_huge.
Copy the icon_huge and rename it to icon_big and scale it down to 32x32 and do it again but name it icon and scale it to 16x16.
After creating the icons, Open the icon file and save it as a targa file (.tga) in the folder, do the same with icon_big and NOT with icon_huge.
Now once you have done all of that, the next step is to show the icon in the steam library. Go to your mods folder and open gameinfo.txt.
Below Gamedata type icon "resource/icon", example:
"GameInfo"
{
	game 		"Your Mod's Name"
	GameData	"portal2.fgd"
	icon		"resource/icon"
	...
Now restart Steam. If it all worked, your mods icon should be shown.
(The guide for creating icon is outdated on steam: Create a Portal 2 mod)
==== Background ====
For this task, you'll need RAD Video Tools.
Fire up RAD Video Tools and find whatever video/image you want to use, then select it and press the Bink it! button in the bottom left corner. Once you've done that, you'll be greeted with a large window that might look a bit familiar to people who have used Windows 95 before. 
If you are using an image and not a video, the only setting we have to touch is the compression setting. Select Compress to a % of the original: and type 100 in the box next to it.
Last but not least, rename your Bink file to 'menu_act01' and click the Bink button that's positioned to the far right of the window. Make sure that the file type is Bink 1 and not Bink 2, as it isn't supported by the .
Finally, create a media subfolder in your mod's main folder and copy over your new bink movie, now enter your Portal 2 mod and it should be there.
==== Loading screens ====
There are two parts to the loading screens, the first part which is shown during the initial mod launch and the second part which is in between test chambers.
Go to Portal 2 folder and open portal2 and open pak01_dir.vpk, then go to . You will find many, .vtf and .vmt files. There are actually 4 loading screens when a test chamber is loading.
Copy all of the .vmt files to your pak01_dir folder in except the files containing e1912 and coop, if your mod is going to have coop then copy those too. 
Now, it's all up to you and to create your backgrounds. Just make sure that every .vtf name matches the name of the .vmt file. Once you're finished, just pack a new VPK and replace the old one in your mod's folder, run a map, and you should be seeing the custom background that you have created yourself.
==== Icon on loading screens ====
First, open . Open the pak01_dir.vpk file located in portal2 folder, and navigate your way to the subdirectory. Find a file named spinner.vmt and copy it to your pak01_dir folder in the .
Open an image editor and create a new file with 128x128, optionally you can have a transparent background and make it transparent. Once you have created your image, save it as a .tga, open .
Import your image and tick the boxes for Compress and Mipmaps, save it to your pak01_dir folder in the . pak it, and replace the old one, open your Portal 2 mod and it should be there.
==== Animated icon ====
By default (in spinner.vtf) there are 7 frames to it (you can have more or less), Open an image editor and create a new file with 128x128, once you have created your image, save it as a .tga, after the name of your spinner type _1 / _2 etc. to keep it organized, and create another one.
Open and import multiple files, hold ctrl and click on multiple files, then change the Texture Type to Animated Texture, tick the boxes for Clamp T, No Mipmap, No Level Of Detail, and Clamp U, save it, pack it and join your game and you should have an animated spinner.
=== Custom audio for background ===
Skip this step if you have a .wav file. (*Create folders...)
If you dont have a .wav file then get a software or a freeware like Audacity to convert the file into a .wav .
Open Audacity and click on file < open, if the files of type is not set to All files then do that first, find the file you want to covert. Once you found the file, go to file < Export Audio, change the format to WAV (Microsoft) and the sample rate to 44100Hz, then export it somewhere on your PC. 
*Create folders in your pak01_dir: , then paste your .wav files, be sure to rename them to portal2_background01 to 05.
Pack it, replace the old one, and open your Portal 2 mod, and you should have custom sound.
== See Also ==
*Create a Mod
*gameinfo.txt
*:Category:Modding
*old revision of this page
Category:Modding
Category:Portal 2 Level Design