Valve Text File Format

From Exterminatus Manual

Jump to: navigation, search

Contents

[hide]

Introduction

When developing the Source game engine valve cooked up a structured text file format that they re-used in several places for storing human readable settings and configurations. EX also makes use of these files for storing mission translations, it's SDK configuration, texture shaders, HUD layouts and more.

These are just text files you can edit them in just about any text editor, I (ChromeAngel) prefer windows notepad or ViusalStudio, but it's really up to you.

The text files are made up of a mix of 3 styles of structure, a name/value pair, named groups and comments

Named Groups

These consist of a Name, followed by whitespace a "opening" curly bracket { any number of name/value pairs, comments or other named groups, then a "closing" curly bracket }. Any leading or trailing whitespace is ignored.

Names must be surrounded by double quotes if they contain spaces or other whitespace. If you're writing your own text files you may as well quote all names and values to be on the safe side.

Groups can "contain" any other parts within their curly brackets {}, it is usual to add leading tabs to items within a group like this, to indent their position to make it clearer they are within the group. For readability the opening and closing brackets are often put on a line on their own to make the text file easier to read.

example

"hammer"
{
}

example with contents

"hammer"
{
	"DefaultSolidEntity"		"func_detail"
}

Name/Value Pairs

Name/value pairs must be within a named group. They consist of a name followed by whitespace (any number of spaces, tabs or line feeds) and a value. Any leading or trailing whitespace is ignored.

Names and Values are usually also surrounded by double quotes, whole numbers and names with spaces in them being the exception to the rule. The source engine seems to be able to cope with quoted whole numbers too, so if you're writing your own you may as well quote all names and values to be on the safe side.

Name/value pairs are usually finished of a with a new line for easier reading.

example

"DefaultSolidEntity"		"func_detail"

Comments

Comments start with two forward slashes // followed by any text and end at the first new line. This is the same style of commenting used by C and many other programming languages.

Anything between a double slash and the end of the line is ignored by the Source engine and can be used to document the use of the file or stop the engine reading name/value pairs or groups without deleting them.

example

//Do not edit this file! It is automaticly generated!

How to break a text file

You can break source engines ability to make sense of one of these text files by braking any of the rules above.

Groups must have both brackets or it wont know where they start or end and can get mixed up with the brackets of groups within the.

Names and with whitespace in must be quoted or the engine will think it ends at the first space/tab/linefeed


See Translation File for an example of this format in use.

Navigation