Traductions possibles :
  • English
  • Français (French)

Ceci est une ancienne révision du document !


III.Source files

page under construction

1.How does it work ?

A Simutrans'object is composed of (most of the time) pictures for display and datas for technical datas of the object. The datas are just written in a simple text file (.txt) but saved with the extension .dat. Easy to do it : when saving your file, replace the .txt extension by a .dat extension. To open your .dat files you have to adjust your computer to open these files with the text editor (notepad with windows). This an example with windows :

Inside the text you can write parameters one after each other but you'd rather write them one below each other for a better aspect. You can put several objects in the .dat file if you separate them with dashes.

for example :

Parameters of the first object

Parameters of the second object

Pictures have other constraints depending on the pakset you create for. The picture must be saved as 24 bits .png (Photofiltre save in 24 bits by default), makeobj can only read .png and if it's a 32 bits .png (with a transparency layer) you'll have a graphical glitch. The dimensions of your pictures must be multiples of the pakset's size. If it's pak128, pictures will 1024*256 or 768*512 for example. If you create for pak64 you'll have pictures of 128*64 or 192*384 for example, etc … If the size isn't right, makeobj will crash.

You have to know how the source pictures work.

The following things is ajusted for pak128, for other paksets you have to change the sizes.

The picture is cut in 128*128 pixels squares (so the picture must have dimensions multiple of 128). This is an example of a source picture part (here is the source picture of the AMT) :

Of course don't draw red shpaes on the source picture, I did so to show you the squares.

Then you'll have to define the squares in the .dat file. Coordinates are used, the first for lines and the second for columns. See here in the same picture :

You'd rather paractice now with coordinates, mistakes occur frequently for a beginner.

The .dat file parameters and the corresponding pictures can be different but can be also very repetitive if you often create the same type of objects, so I will give you graphical shapes and .dat shapes for you to make your files easier, objects will be described one by one.

A picture is defined in a .dat file as this :

internal_id_of_the_picture=name_of_the_picture_witheout_the_extension.line.column

example : imageUp[3]=AMT.3.3

the picture used for imageUp[3] is the square on the intersection of the fourth line and the fourth column of AMT.png.

Graphical shapes given here are made for the standard pak128, there can be differences with the other pak128. These graphical shapes are made for .dat shapes given with, be careful if you modify the position of objects…
In .dat files, every parameter is written as here :
parameter=value

Every number is integer. The text respects shift.

2.Offset

The offset allows you to move the picture in some situations. This technic must be used only in necessary situations, it musn't be used instead of the moving directly the graphics on the picture.

How to use the offset :

id_picture=name_picture.line.column,x,y

x is the number of pixels to the right and y is the number of pixels to the bottom.

In the example below, the picture is moved of 16 pixels to the top.

cursor=SNFOSstationsmodern.1.7,0,-16

3.Utiliser votre éditeur de texte

1.Windows

Under windows, notepad is used and NOT another text editor. It's accessible in the start menu\programs\accessories\notepad. The useful tools of notepad are the research tool and the replace tool that you find in the edition menu.

These tools are accessible bia the keyboard shortcuts ctrl+f and ctrl+h

Be careful using the tool “replace” if you use the icon “replace all”, it can modify some text parts which aren't supposed to be.

Finally, to save a source file for Simutrans, replace the default extension ”.txt” by the extension ”.dat”.

2.Linux

Linux has many text editors. They often depend on the release, or on the installed desktop manager. The best thing to do is to see the documentation given with your text editor to know its keyboard shortcuts.

Some examples : Gedit, Kate, Leafpad…
I deal with text editors, not with text treatment softwares. OpenOffice writer isn't made for this use !

To save a source file for Simutrans, the process is the same as windows, you just have to use the extension ”.dat” for the file.

Be careful, if you work on linux and windows, the wrap symbols aren't the same on the two OS. A file created on the one can be strangely displayed on the other one. You'd rather work on only one OS if you don't know the conversion commands.

4.Objects

5.Pages annexes