免費論壇 繁體 | 簡體
返回列表 发帖



NOTE TO AUTHORS: Read the LocalStyleGuide, otherwise the page may be rolled back to the last well-commented edit. (This applies everywhere, not just on the pages that mention it.)
To write:
- explain GRFCodec / GRFWizard
- explain hex codes: specific examples using Windows calculator, ideally with screenshots
- maybe: explain DOS/Windows version and how to convert between them
- other things?

What's a .GRF file?


As you probably already found out ttd can load new graphics files with help of the patch. These files have the extension .grf and are located in the newgrf folder.


These .grf files are made by the GRFcodec, this program merges a .pcx file and a .nfo file. (links to george his tut now, but I think on top of that page should be an explanation about pcx files and their pallete ) In this tutorial we won't look at those 2 file types yet, at first we shall try to explain the basics.

这些.grf文件是由the GRFcodec生成的,这个程序用来合并.pcx 文件和.nfo文件(链接到george的关于绘制.pcx的教程),在这个教程里,我们将首先解决基本的,而不是以上两个文件的说明。

The GRFCodec and the GRFWizard

程序GRFCodec 和GRFWizard

Like said before a .grf file is a file made by the GRFCodec. The codec is a package of 3 programs:
1. GRFCodec: Convert a GRF into an editable PCX file and vice versa
2. GRFDiff: Compare two GRF files for differences, and write only the differences to a GRD file
3. GRFMerge: Take a GRD file and merge it back into the GRF file

1、GRFCodec :转换.grf,包括编译和反编译;

In this tutorial we will only use the first program, if you want more info about the other programs look here.
The GRFCodec is a command line program. This means it's option are only been set in the command line, there is no nice user interface. For the nice interface you can download the GRFWizard This program is really helpful. Be warned though for the GRFWizard to work you need the GRFCodec too.


When you run the GRFWizard for the first time you have to point it to the codec, when you have done this everything is really straight forward, you can encode your homemade sprites (sprites are the little drawings that represent one side of a building/vehicle) or you can decode a grf from someone else.


When you want to encode graphics you have to point the wizard which grf file you want to encode the 2nd step is to tell it in which you placed the NFO and PCX. All these file should have the same name.


If you want to encode totally new graphics you have to make a "fake" grf. Just make a new txt file and rename it to the grf you want to encode.
If you choose to decode a grf, the nfo and pcx will be extracted to a map called sprites in the in the folder where you placed the grfcodec in.


Hex 十六进制
some sort of text here to explain why you need to understand hex?


HEX is a way of counting. You normally count from 1 till 9 and then go to 10,11 etc. In HEX it works a bit differently: you count from 0 till 9 but then you go one with A, B,C,D,E,F. So 1 till 9 is just 1 till 9, but then it gets funky A=10, B=11, C=12 and so one till F= 15. when you reach F you just do like you would do normally, you start at 0 again but now with a 1 in front thus 10 (gee thats almost like normal counting! ) so 10=16 If you want a better understandable explanation visit this link.

Now it would be rather uneasy if you have to count it all by yourself (or at least for me being of the lazy generation) so you can use the windows calculator for that.
If you open it it take any hex, so you have to go to scientific. Just open view and click on scientific mode.
If you did it correctly it will look like this:

(sorry I had to eat, I will see this page later on again)
收藏 分享

文涛武略 发表于 2008-5-28 16:37
NFO Filesnfo文件

The fundamental files that control your new graphics are the .nfo and the .pcx file. The .pcx file contains the actual drawings, and the .nfo file the instructions what to do with them.


To get started开始

To draw a new train, you first need a base from which to start working. Since you probably aren't familiar with all the intricacies yet, it's best to copy one of TTD's vehicles and then draw your own graphics. Basically, you follow these steps:


  • Extract TTD's trg1r.grf (or trg1.grf for the DOS version)
  • Look through trg1r.pcx for a vehicle similar to the one you're going to make
  • Copy the corresponding data from the .nfo file into your own file
  • Encode and decode again your own file

Now to look at these steps in a bit more details.

1. Extract TTD's trg1r.grf1、解压ttd的trg1r.grf

First of all, you need to download grfcodec and unzip it into your TTD folder. Then you open a DOS command window. If you are using Windows 2000 or Windows XP you can open a DOS command window by typing cmd in the execute option in the start menu. When you see the command window run grfcodec like this:


cd C:\TTD (change to your TTD folder)
grfcodec -d trg1r.grf (decode trg1r.grf; use trg1.grf for the DOS version of TTD)

This will make a new folder called sprites, and will put trg1r.pcx and trg1r.nfo in it.


You can also use GRFWizard with grfcodec. It will add a user interface to grfcodec. Just follow the options in the wizard to decode a .grf file, it will also add a sprites folder and generate the .nfo and .pcx files.


2. Look through trg1r.pcx2、查看trg1r.pcx

You now open trg1r.pcx from the sprites folder. There are many graphics programs to view and edit .pcx files.

Look for a vehicle that is similar to the one you want to make. For example, if you want to make a train engine with 8 views, you can use the SH 125. So you go looking for its graphics in trg1r.pcx. For the SH 125, you'll find them at numbers 2941 to 2948 (those are the little numbers above the images). Write down those numbers. For example, this is what it might look like:

找到一个与你想要绘制的图形相似的运输工具。例如,你想要绘制一个火车头的8方向图,你可以查看SH 125。对于SH 125来讲,你可以看到他们的数字为2941到2948(在相应图像上的小数字)。如图所示


3. Copy the corresponding data from the .nfo file into your own file3、从.nfo文件中拷贝相应的数据到你自己的文件中

So now that we know what sprites to base the graphics on, we need to copy those into a new file. Open the trg1r.nfo file in a text editor, for example Notepad. Also, open another .nfo file for your own graphics, say for example "mytrain.nfo".

现在,我们知道了相应的图形对应的数字,我们需要拷贝这些数据到新的文件里。用文本编辑器打开trg1r.nfo,例如 notepad。同样的,创建一个名为“mytrain.nfo”的文件。

Now, copy and paste the first three lines beginning with "//" to your mytrain.nfo file. While they may look like comments, they are actually important.


In the next step, find the lines beginning with the sprite numbers you're written down in the previous step. In the example above, we'd find the lines with numbers 2941 to 2948. Copy those eight (or however many) lines to your mytrain.nfo file as well.


4. Encode and decode again your own file编译和反编译你的文件

Now we want to make our own .grf file. Unfortunately, grfcodec is a bit picky and will complain loudly if your lines are not numbered properly. To make grfcodec shut up, you have to go through your .nfo file, and change the numbers at the beginning of the lines to go from 0 to 7.


At this point, your .nfo file should look something like this:

// Automatically generated by GRFCODEC. Do not modify!
// (Info version 6)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
0 C:\TTD\SPRITES\trg1.pcx 530 10664 01 18 8 -3 -10
1 C:\TTD\SPRITES\trg1.pcx 546 10664 09 15 20 -14 -6
2 C:\TTD\SPRITES\trg1.pcx 578 10664 01 12 28 -14 -6
3 C:\TTD\SPRITES\trg1.pcx 626 10664 09 16 20 -4 -8
4 C:\TTD\SPRITES\trg1.pcx 658 10664 01 18 8 -3 -10
5 C:\TTD\SPRITES\trg1.pcx 674 10664 09 16 20 -14 -7
6 C:\TTD\SPRITES\trg1.pcx 706 10664 01 12 28 -14 -6
7 C:\TTD\SPRITES\trg1.pcx 754 10664 09 15 20 -4 -7

Now run grfcodec again, first to encode and then to decode your file. This creates mytrain.pcx and changes your .nfo to refer to that copy of the sprites:


grfcodec -e mytrain.grf (encode your mytrain.grf file)
grfcodec -d mytrain.grf -p 2 (decode your mytrain.grf file again)

Leave off the "-p 2" if you're working with the DOS graphics instead of the Windows graphics.
“-p 2”命令开关是用来生成DOS版本的grf

Good job!做得好

Now you have your own mytrain.grf file with the corresponding mytrain.nfo and mytrain.pcx files. We'll use this as a base for making these graphics TTDPatch compatible.


Note that you can't yet take your mytrain.grf file and put it in TTDPatch's newgrfw.cfg file yet, because it doesn't have the necessary information to allow TTDPatch to know what to do with it.


However, you can go ahead and edit the graphics in mytrain.pcx to your liking and make them look like your train.

Once you're ready, go on to the next section.

文涛武略 发表于 2008-5-28 17:24
The First Vehicle第一个运输工具

This section of the tutorial takes the rudimentary mytrain.grf file you made in the previous step, and turns it into a .grf file usable by TTDPatch.


Here's what you have to do:

  • Figure out "pseudosprites"
  • Add the special first pseudosprite
  • Give your file an GRFID
  • Add an "action 1" to introduce your vehicle graphics
  • Use actions 2 and 3 to link your graphics to a vehicle in TTD
  • Adjust the first pseudosprite again, and renumber all sprites
  • Encode and add to newgrf(w).cfg
4、增加"action 1 "来介绍你的grf文件


  • Figure out "pseudosprites"
  • Add the special first pseudosprite
  • Give your file an GRFID
  • Add an "action 1" to introduce your vehicle graphics
  • Use actions 2 and 3 to link your graphics to a vehicle in TTD
  • Adjust the first pseudosprite again, and renumber all sprites
  • Encode and add to newgrf(w).cfg
4、增加"action 1 "来介绍你的grf文件

Now let's look at this in more detail.

1) Figure out pseudosprites1、弄明白"假sprites"

If you've looked through trg1r.nfo, you may have noticed that some entries look different to the usual ones.

Usual entry:

24 C:\TTD\SPRITES\trg1r.pcx 450 8 01 9 7 0 0

This one is different:

771 * 17 10 00 F0 F0 F0 F0 F0 F0 F0 F0 F0 F0 F0 F0 EF EF EF

The first one refers to an image in the PCX file. The second one is some additional data that's not an image. These types of entries are called "pseudosprites", and in TTDPatch .grf files they are used to give TTDPatch information what it should do with the graphics in the file.


Here's what you have to know:

  • The first number is the well-known sprite number, simply counting entries from the beginning of the file
  • Then follows an asterisk "*", where you would normally have the PCX filename
  • Then there's another number, which is the length of the following data
  • And finally the actual data, as a bunch of hex codes

So, that's what you have to know about pseudosprites for now. Let's get started...

2) Add the special first pseudosprite添加特殊的第一个“假sprite”

For TTDPatch graphics files, the first entry in the .nfo is special, and tells TTDPatch how many lines the file has. Since we don't yet know how big it will be, we add it but don't put any useful data in.


Here's what you do: in your mytrain.nfo file, after the comment lines (those that begin with "//"), but before the first entry, insert the following line:


0 * 4 00 00 00 00

3) Give your file an GRFID3、标注grfid

Apart from the first line which we've added in the previous step, TTDPatch .nfo files are organized by "actions". These actions tell TTDPatch what to do with the graphics in your file. In our specific case, we need to tell TTDPatch to use those graphics for a train engine.


Before you go any further, just let me make clear what the different ID's mean that we will refer to. Here's a table:


ID TypePurpose
Vehicle IDA generic vehicle/station/building slot whose properties can be defined using an Action 0. A Cargo ID can be associated with this using Action 3.
set ID (called cargo ID for vehicles)A ID asociated with one or more Spritesets using an Action 2. Can be asociated with a Vehicle ID using Action 3.
SpritesetA value unique to each Action 1. Defines a set of 8/4 views i.e. a set of sprites. Is in an action 2
GRFIDA word value used to differentiate between different grf files. This should be globally unique!

ID 类型目的
运输工具 ID通过使用脚本0来定义运输工具/站台/建筑的统一接口。货物ID通过使用脚本3来产生联系
固定ID (运输货物类型的ID)
A value unique to each Action 1. Defines a set of 8/4 views i.e. a set of sprites. Is in an action 2

Just keep that in mind and refer to it later on.
Now, lets continue.


The first step to do that is by using an Action 8, which gives your file an GRFID, and allows people to turn it on or off in the GRF Status Window.


You have to choose the GRFID yourself. To find a good GRFID to use, for example use the initials of your first and last name, plus two numbers.


For example, for this tutorial, we'll use the initials "TW". In addition, we need two numbers to identify the file. These you can pick however you like, you'll use them to distinguish different graphics files made by you. Those will have the same initials, but must get different GRFIDs, so you pick different numbers. For example, here we pick 3 and 5.


This means we get the following GRFID:

"TW" 03 05

You may also write the initials as hex codes. If you aren't familiar with hex codes, you can use the Hex Converter to help you. Simply enter your initials and click convert, and then write down the hex codes. This is more complicated, so very few people do it, but the result would be the following equivalent GRFID:

54 57 03 05


This form is the official form for a GRFID, and should be used in all non-.nfo contexts. In .nfos, you may use whichever form you prefer.


The 54 57 are the hex codes for "TW". In both cases, 03 and 05 are the numbers we've picked, written in hex.

54 57 是"TW"的十六进制表达式,同时,03 05是我们选择的数字,也是以十六进制表达的。

Therefore, you insert the following line immediately after the line which you've added in the previous step:
1 * 8 08 06 "TW" 03 05 00 00


This gives your graphics file the GRFID. This action 8 must always be present in your files, and it must be one of the first lines. If you don't have an action 8, TTDPatch will complain about "invalid sprites" or an "incorrect version", and refuse to load your file.


You can optionally give your file also a name and a description or copyright info, but that's beyond the scope of this tutorial. Check the docs for action 8 for more details.



4) Add an action 1

Right, so now the file has an GRFID. In the next step, we need to tell TTDPatch that there will be a bunch of graphics in this file. You might think that that's obvious, but nothing is obvious to computers, so we have to tell it.


This happens through an Action 1 entry, that tells TTDPatch there will be one or more sets of graphics in the file. In our case it looks like this:
2 * 4 01 00 01 08


Add this line right after the above action 8. It's worth decoding what this line means. you can just read it from the left to the right. We have the following:


01Action 1
00Feature 0, meaning trains
01One set of graphics
08Each set has eight views

00特征 0, 代表火车

For more details on these, in particular to see what "features" there are, check the Action 1 docs.


After this follow the eight lines with the actual graphics that we already have in the .nfo file. So at this point your file should look something like this:


// Automatically generated by GRFCODEC. Do not modify!
// (Info version 6)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
0 * 4 00 00 00 00
1 * 8 08 06 "TW" 03 05 00 00
2 * 4 01 00 01 08
0 C:\TTD\SPRITES\mytrain.pcx 66 8 01 18 8 -3 -10
1 C:\TTD\SPRITES\mytrain.pcx 82 8 09 15 20 -14 -6
2 C:\TTD\SPRITES\mytrain.pcx 114 8 01 12 28 -14 -6
3 C:\TTD\SPRITES\mytrain.pcx 162 8 09 16 20 -4 -8
4 C:\TTD\SPRITES\mytrain.pcx 194 8 01 18 8 -3 -10
5 C:\TTD\SPRITES\mytrain.pcx 210 8 09 16 20 -14 -7
6 C:\TTD\SPRITES\mytrain.pcx 242 8 01 12 28 -14 -6
7 C:\TTD\SPRITES\mytrain.pcx 290 8 09 15 20 -4 -7

However, if you're doing this for one of your files, you have to choose your own GRFID of course because 54 57 03 05 is reserved for the file we're making in this tutorial.

然而,你需要修改grfid,因为54 57 03 05是教程专用的。

5) Using actions 2 and 3

At this point, TTDPatch knows the GRFID of your file, and it has loaded the graphics for it. The only thing that remains to be done is linking these graphics to one of TTD's vehicles. Note that you can't add new vehicles as such, you can only replace existing ones. This means that you also have to decide which one to replace, so you have to find out the vehicle ID of that vehicle. Since we've based the graphics on the SH 125 here, we might as well replace that one, although you're free to use whichever vehicle you want. There's a list of vehicle IDs here. You can pick any train number from the list, don't forget to convert the number to hex.
Warning: You can only replace trains with trains and ships with ships and so on.

这时,TTDpatch已经知道你的grf文件的grfid了,并且加载了图形。剩下的就是将这些图形与ttd里的运输工具产生替换。注意,你不能添加新的运输工具,你只能替换已有的。这就意味着你可以考虑替换哪一个,因此你需要找出该运输工具的ID。既然我们基于的SH 125,我们最好是替换它,虽然你有自由选择权。这里有一个运输工具ID的列表,你可以从列表中找到一个,别忘了把ID转换成十六进制。

To associate graphics with a vehicle, we use Action 2 and Action 3. Action 2 is called a "cargo ID", because it contains various states of animation of one particular cargo. This isn't really important for the train engine we're making, but for example wagons may be able to carry different cargos that should also look differently.



For our train engine, we define one cargo ID like this:
11 * 9 02 00 00 01 01 00 00 00 00


This is already getting a bit complicated, so let's look at it in detail:


02Action 2
00Feature 00, meaning trains
00We define Cargo ID 0 (the first number available)
01There is only one set of graphics we have while in motion
01And also only one set while loading
00 00Use the first set while in motion
00 00And also while loading/unloading

00特征00 ,代表火车
00我们定义货物 ID 0 (第一个可用的数字)
00 00在运行中,使用第一个系列
00 00在装/卸载中也使用第一个系列

Instead of cargo ID 0, we could have defined any other number, but it makes sense to start with the first number.


Regarding the number of sets, it's possible to show various states of animation depending on how full the vehicle is, and whether it's in motion or whether it's loading or unloading. However, for train engines that's unimportant, so we'll forget about it for now.


The last sets of two 00 codes tells TTDPatch which sprite-sets to use, referring to the most recent action 1. Since we've only had one set there, and sets are numbered starting from 0, that means we have set 0. We put down the set number 00, followed by another 00 because TTDPatch needs that. If we were using set 1, it would be 01 00.

最后的代码设置为00 00 来告诉TTDPatch使用哪一个sprite系列,指向最近的脚本1。既然我们这里只有一个系列,并且编号从0开始的。因为记为00,紧跟的00 是因为ttdpatch需要它。如果我们需要使用系列1,将是01 00

This is our cargo ID definition. Now we attach this cargo ID to the vehicle using action 3. The SH 125 has vehicle ID 22, or 16 in hex, so we use the following:
12 * 7 03 00 01 16 00 00 00

这是我们的货物id定义,现在我们通过脚本3给这个运输工具赋予货物id,SH 125 的运输工具ID是22,十六进制为16,因此我们这样写:

Again in more detail:

03脚本 3
00特征 00, 代表火车
16运输工具的 ID是 16 (十六进制)
00 00在任何情况下都使用货物ID为0

We could give the same graphics to several vehicles, but that's usually not useful. For wagons, we could also define various cargo IDs and attach them depending on what cargo the wagon carries, but for engines that doesn't matter and so we just use cargo ID 0. Again the first 00 refers to cargo ID 0, and the second 00 is required because TTDPatch needs it.


At this point, we only need one more action: we need to tell TTDPatch to actually use these new graphics. Action 3 only says if the vehicle uses new graphics, then these are what it should use. To actually make it use new graphics we use Action 0, like this:
13 * 7 00 00 01 01 16 12 FD


In more detail:

00Action 0
00Feature 0, meaning trains
01We set one property
01For one vehicle
16Starting at vehicle 16
12We set property 12 (sprite type)
FDAnd we set it to FD

00特征0, 代表火车
16从运输工具ID 16开始
12设置属性12 (sprite 类型)
FD属性参数设置为 FD

We could set more than one property to give the vehicle for example different power and speed, but for now we only want to see the new graphics, and for trains that means we need to set property 12 to FD, which tells TTDPatch to use new graphics for this vehicle ID. For the other property, check the action 0 docs.

我们可以对运输工具设置多个属性,例如不同的动力和速度,但现在我们只是设置替换图形,对火车而言,我们需要设置属性12 为FD,将告诉TTDpatch对这个ID的运输工具来使用新的图形,其它属性,请查看脚本0的文档

6) Adjust and renumber

Now we're basically done, we told TTDPatch what graphics to use for what vehicle. We only need to renumber the file and adjust the first pseudosprite. So you go through all the entries, make sure they start at zero and that the following number increases by one. In this case, the last number ends up being 13.


Now we have to adjust the first entry, because it needs to tell TTDPatch how many lines to expect for the rest of the file. Since the last line is 13, we set it to 13, but we have to write it in hex in little endian format. 13 in hex is D, which has to have zeroes added from the left to make eight digits, or 0000000D. Now you cut these into groups of two (00 00 00 0D) and write them in the opposite order (0D 00 00 00). That's what you put in the first entry.

现在我们要调整第一段落,因为需要告诉ttdpatch剩余有多少行。既然有13行,我们设置为13,但是我们必须使用十六进制的D来表示13。因为需要增加0来满足8位数,例如0000000D。现在将它们按两位一组分隔开来(00 00 00 0D),然后反过来写(0D 00 00 00),这就是你第一段落的内容。

Now your mytrain.nfo file is done, and it should look like this:

// Automatically generated by GRFCODEC. Do not modify!
// (Info version 6)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
0 * 4 0D 00 00 00
1 * 8 08 06 "TW" 03 05 00 00
2 * 4 01 00 01 08
3 C:\TTD\SPRITES\mytrain.pcx 66 8 01 18 8 -3 -10
4 C:\TTD\SPRITES\mytrain.pcx 82 8 09 15 20 -14 -6
5 C:\TTD\SPRITES\mytrain.pcx 114 8 01 12 28 -14 -6
6 C:\TTD\SPRITES\mytrain.pcx 162 8 09 16 20 -4 -8
7 C:\TTD\SPRITES\mytrain.pcx 194 8 01 18 8 -3 -10
8 C:\TTD\SPRITES\mytrain.pcx 210 8 09 16 20 -14 -7
9 C:\TTD\SPRITES\mytrain.pcx 242 8 01 12 28 -14 -6
10 C:\TTD\SPRITES\mytrain.pcx 290 8 09 15 20 -4 -7
11 * 9 02 00 00 01 01 00 00 00 00
12 * 7 03 00 01 16 00 00 00
13 * 7 00 00 01 01 16 12 FD


7) Encode and add

Now all we have to do is encode the file:


grfcodec -e mytrain.grf

and then add it to newgrf(w).cfg to test it!


Make sure to check the GRF Status Window to see that your file is enabled. If not, click on its red flag and then click "apply". If you get any error messages, write down the sprite number that's incorrect, and then fix the mistake in the corresponding line in the mytrain.nfo file.


Further reading

Basically, now you know most of what's needed to make your own graphics. Further details can be found in the GRFActionsDetailed page, which tells you everything about all the actions there are.


The next few sections will cover in some more detail the most common tasks for making new graphics, but other than that you're on your own now!


[ 本帖最后由 文涛武略 于 2008-5-28 19:30 编辑 ]


Action 0脚本0

Defining new graphics feature properties


What does it do?


Action 0 is similar to TTDAlter in that it changes the feature properties of 'features', i.e. vehicles, stations, bridges, houses and more. That means that you can change properties like:


  • vehicle introduction date
  • top speed
  • wagon capacity
and many more.




The data for Action 0 looks as follows:


<Sprite-number> * <Length> 00 <Feature> <Num-props> <Num-info> <Id> (<Property <New-info>)...

Here is a short overview of what every term means:

<Sprite-number> decA sequential sprite number
<Length> decThe total number of bytes in the action
00 BAction type. In this case, 00
<Feature> BWhich type of feature you would like to change
<Num-props> BHow many properties you would like to change per vehicle or station
<Num-info> BHow many vehicles/stations you would like to change
<Id> B*The ID of the first vehicle/station to change
<Property> BWhat property to change for each vehicle/station
<New-info> VThe new value of the property

<Sprite-number> decsprite编号
<Length> dec在这个脚本的数据总量
00 B在本例中,定义为脚本0
<Feature> B你想要修改哪类特征
<Num-props> B你想要修改一个站台/运输工具的多少个属性
<Num-info> B你想要修改多少个站台/运输工具
<Id> B*第一个要修改的站台/运输工具的ID
<Property> B每个站台/运输工具的哪一个属性需要修改
<New-info> V修改后的属性值

You can put an Action 0 anywhere after Action 8 in the GRF file.


The <Id> is an extended byte since 2.0.1 alpha 61, to support the definition of >255 sound effects.

从ttdpatch2.01.alpha 61 后,id字段被扩展用以支持>255的音效定义

Filling in the terms

Sprite-numberAction 0 can appear anywhere in the GRF file, so set it to the sprite number you are currently at.


LengthThe total number of bytes in Action 0. Start counting from <Action>, the bit that sets the pseudo-sprite to act as the specified action.


ActionThe type of action this pseudo-sprites defines. It should be 00 here because we want this pseudo-sprite to act as Action 0.


FeatureThis sets the type of feature that you wish to change. Set it to:

00 for trains    火车
01 for road vehicles    汽车
02 for ships       轮船
03 for planes        飞机
04 for stations       站台
05 for canals        隧道
06 for bridges      桥梁
07 for houses (see defaults)   房屋(查看默认)
08 for global variables     全局变量
09 for industry tiles (see defaults)   
0A for industries (see defaults)     工业
0B for cargos (see defaults)    货物
0C for sound effects       音效
0D for airports (No official properties)   机场(非官方属性)
0E for signals (Action 0 is not valid for this feature)  信号灯(脚本0不可用在这个特征上)
0F for newobjects  新事物

Note that the above list is the master list for all actions where not stated otherwise.


Num-propsThis is the number of properties that you wish to change per vehicle or station. Note: even if you wish to set the same properties to the same value for different vehicles then you must still repeat the properties and their values for each vehicle.


Num-infoSimply the number of vehicles that you will change using this action 0.


IdThe Vehicle ID of the first vehicle or station to change. If num-info is greater than one, this vehicle/station and the following vehicles/stations will be changed.


PropertyThe number of the property that will be changed. This and the New-info section are repeated as many times as there are properties to set; in total, there are <num-props> property bytes.
See relevant sub-section (links at the bottom) for more details.


New-infoThe new information that will replace the previous information for the specified property. This is a variable size; dependent upon the property. Each property byte is followed by <num-info> new-info sections.


The appropriate \b, \w, and \d escape sequences can be quite useful for most <new-info>s. See the discussion of escape sequences for further information.


Features and properties

Each feature has its own very specific properties. These are explained in detail in the pages listed below:


    Action0General - Action 0 properties common to all vehicle types   脚本0中所有运输工具类型的通用属性Action0Trains - Action 0 properties for trains  脚本0中火车的属性Action0RoadVehicles - Action 0 properties for road vehicles  脚本0中汽车的属性Action0Ships - Action 0 properties for ships  脚本0中轮船的属性Action0Planes - Action 0 properties for planes  脚本0中飞机的属性Action0Stations - Action 0 properties for new stations 脚本0中新站台的属性Action0Canals - Action 0 - Properties for canals / rivers 脚本0中隧道/河流的属性Action0Bridges - Defining properties of bridges 桥梁的属性定义Action0Houses - Action 0 properties of houses 脚本0中房屋的属性
    • DefaultHouseProps - Default property values for TTD's houses ttd中房屋的默认属性
    Action0GeneralVariables - Action 0 properties for general variables 脚本0中全局变量的属性Action0IndustryTiles - Action 0 properties for industry tiles 脚本0中Action0Industries - Action 0 properties for industries 脚本0中工业的属性Action0Cargos - Action 0 properties for cargo types 脚本0的货物类型的属性
    • CargoDefaultProps - Default property values for TTD's cargo types TTD中默认的货物类型属性
    Action0SoundEffects - Action 0 properties for new sound effects 脚本0中新音效的属性
  • Action0Objects - Action 0 properties for new objects 脚本0中新事物的属性

You will also find the minimum GRF version (in Action 8) that supports this property, or alternatively if the property was introduced between version changes, the patch version number that you can check with Action 7.



For examples please see the action 0 entries for each feature.



Action 0 - General properties for all vehicle types

Defining properties of vehicles.


The four vehicle types (trains, road vehicles, ships and planes) all have some common properties, which are described here.



00Wdate of introduction
02Breliability decay speed
03Bvehicle life in years
04Bmodel life in years
06Bclimate availability
072Bload amount



Properties 00 to 06 only apply to new games, or when using Cht: ResetVehicles.




Date of introduction

The date is specified as number of days since 1920 where TTD counts 365,25 days in a year. It will have a random number from 0 to 511 days added to it at the start of every new game, or after using "Cht: ResetVehicles". Note that TTD stops updating vehicle type data after the game ends in 2050, so all dates of introduction should be no later than in 2044, to ensure that all vehicle types can be introduced and reach their maximum reliability.


If the property value is 729 (2D9h) or less, i.e. before 1922, the random number is not added and the vehicle is introduced at exactly the given date.


The \w<date> escape sequence is especially useful here. See the discussion of escape sequences for further information.


Reliability decay speed

The reliability decay speed is set when a new vehicle is bought, and specifies how quickly the reliability decays after servicing. The initial TTD default for all vehicles is 20. If a vehicle goes without servicing for a long time, or if it gets very, very old, this number increases, meaning faster decay and more breakdowns. Larger numbers mean faster decay, smaller number slower decay. If set to 0, reliability never decreases in normal operation.


Vehicle life

The number of years before a particular vehicle is considered too old and needs replacing,


Model life

The number of years that this model can be bought in the game (if PersistentEngines is off). Usually this should be at least twice or three times as long as the vehicle life. When starting a new game, a random amount between 31 months and 17 years is added to this as well.


If the early retirement property (26/1B/16/16) is not set, the model life works like this:


17 to 38 monthsincreases from 48-73% to 75-100%
2prop. 04 less 8 yearsstays constant at peak, 75-100%
310 to 20.5 yearsdecreases from peak to 25-50%

17 -38月由 48-73% 增加到 75-100%
24- 8年保持在 75-100%
310 -20.5年衰减到 25-50%

(the ranges in time and reliability are randomized at the start of each game)


At the end of phase 3, the model is retired and removed from the purchase list. Note that when the model reliability starts dropping in phase 3, so does the reliability of every single vehicle of this make in the game.


If persistentengines is on, the model never gets to within two years of the end of phase 2, it is kept in phase 2 as long as at least one vehicle of this make is in the game.


If the early retirement property is set, the vehicle is retired this many years before the end of phase 2 (can be negative if desired), but not if persistentengines would keep the model alive.


Climate availability

This is a bit mask of the climates in which this model is available. Simply add the values for the climates:




For example, 1+2+4 = 07 would make a vehicle available in all climates except Toyland.


Load amount

This is the amount of cargo transferred per unit of time if using gradualloading. The default is 5 for trains and road vehicles, 10 for ships and 20 for aircraft.



提示: 作者被禁止或删除 内容自动屏蔽