News:

Simutrans Sites
Know our official sites. Find tools and resources for Simutrans.

[TUTORIAL] Creating an addon (I): Introduction

Started by vilvoh, September 06, 2009, 06:10:30 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

vilvoh

Author: IgorTekton
Translation: Vilvoh
Aspect: development
Level: average
Summary: Introduction to the process of creating an addon

Note: If you're going to use this content, please mention the author of the content or place a link to the original source where you get this content.




1. Introduction

This tutorial is the first part of a series of four that will show you how to create an addon on pak format. This one is short but it's focused on the stuff you need to start creating an addons.

2. Choosing the right tools

For creating an addon, you need at least three kinds of programs:

  • Image Editor: it's necessary to make the png images of vehicles, tracks o any other object from the game. We recommend you to use GIMP, Paint.net, MS Paint, Photoshop or PaintShop Pro. The images must be saved in png format.
  • Text editor: it will be necessary to create the dat files. A dat file is just a text file saved with dat file extension, that containts simple instructions to help Simutrans to recreate the object on the scenario from the images and the attributes. We recommend you to use Notepad, Notepad++, PSPad or Vim.
  • Makeobj: this program will merge the png images with the attributes contained in the dat file, in order to create a file in pak format, that will be used by the game to represent the object. This time there's no alternative but don't worry, this program has been developed by the Simutrans developers.

3. A quick overview of the addon's creation process.

3.1. What does a pak file contain?
The pak file simply hosts the information from two different files:


  • An file of images in PNG format: it's the visual representation that will be used by the game engine to represent the object inside the game.
  • A text file in dat format: it's a small file that contains the attributes and instructions that define the object and its behaviour inside the game. Otherwise, how is Simutrans engine going to know who's who?


Above, you can see a screenshot that shows part of a dat file on the left side and the png file that contains several views of a highway.

3.2. The process, step by step

This is a brief summary of the process. Each step will be explained in deep with an independent tutorial.

  • You must paint the different images of the object using the image editor. The images must be saved in PNG format.
  • You must create and write the DAT file, using the png images as reference. You may need to include several extra attributes depending on the type of object you want to create.
  • Now you have the PNG and DAT files, you need to merge them in a pak file using Makeobj

Escala Real...a blog about Simutrans in Spanish...

edson

This was not translated!  ;)
Quote from: vilvoh on September 06, 2009, 06:10:30 PM
3.1. What does a pak file contain?
Um arquivo pak nada mais é que uma junção de dois arquivos:

vilvoh

Opsss!! don't blame me.. it's copy-and-paste fault!  :P

Escala Real...a blog about Simutrans in Spanish...


leski

Where can I find a FULL and TRUE list of parameters and its values in the .dat files? For instance, the FREIGHT parameter - the general, multifreight values, elsewehere claimed to be named CATEGORY_01 through CATEGORY_06, actually make the game crash.

The Hood

It depends on the pakset.  The best solution is to call the freight= parameter as the name of the correct type of good as defined in the goods.*.pak file(s).

e.g. in pak128.Britain "meat" is a cooled good, so vehicles for transporting cooled goods have "freight=meat" set in the dat file.

vilvoh

Quote from: leski on November 14, 2009, 05:35:59 PM
Where can I find a FULL and TRUE list of parameters and its values in the .dat files?

I calculate that there're more than 50 parameters and the double or more possible values, so right now it's quite difficult to gather all. Only some of them are common to all types of objects, the rest depends on the object you want to create.

You've a short summary at http://simutrans-germany.com/wiki/wiki/tiki-index.php?page=de_dat-Dateien&bl=y

Quote from: leski on November 14, 2009, 05:35:59 PM
For instance, the FREIGHT parameter - the general, multifreight values, elsewehere claimed to be named CATEGORY_01 through CATEGORY_06, actually make the game crash.

The wiki page with all possible values of freight parameter for the different paksets is this one: http://simutrans-germany.com/wiki/wiki/tiki-index.php?page=de_dat-Dateien&bl=y

Escala Real...a blog about Simutrans in Spanish...

leski

#7
Quote from: The Hood on November 14, 2009, 05:38:35 PM
It depends on the pakset.  The best solution is to call the freight= parameter as the name of the correct type of good as defined in the goods.*.pak file(s).

Well, I'm solely using pak64, still hardly running on my Athlon 1100 with DDR I 267 MHz RAM... ;) But, it's not what I'm looking for. I'll be more precise in the next message :)




Quote from: vilvoh on November 14, 2009, 06:00:05 PM
I calculate that there're more than 50 parameters and the double or more possible values, so right now it's quite difficult to gather all.

Still should be possible :) Do U mean the only way is to examine the game source files?

Quote from: vilvoh on November 14, 2009, 06:00:05 PM
Only some of them are common to all types of objects, the rest depends on the object you want to create.
Well, I mean vehicles :)

Quote from: vilvoh on November 14, 2009, 06:00:05 PM
You've a short summary at http://simutrans-germany.com/wiki/wiki/tiki-index.php?page=de_dat-Dateien&bl=y

It's still not what I need. The following page: http://en.wiki.simutrans.com/index.php/Freight_category lists, for instance, books, ink, chemicals, medicines, furniture etc. as belonging to one category - "Boxed goods". In the game, there obviously are rail cars capable of transporting any good belonging to this category. The question is, how to define the FREIGHT value in the vehicle's dat file so as to achieve this goal? Supposedly I should use the "Internal name", but CATEGORY_01 crashes the game. Should I try German KATEGORIE_01? ;)

DirrrtyDirk

No, you simply have to use one specific good that is part of the category you want, and all other goods from this category will be enabled to load as well. That's the only way it works.
  
***** PAK128 Dev Team - semi-retired*****

leski

Quote from: DirrrtyDirk on November 14, 2009, 09:44:15 PM
No, you simply have to use one specific good that is part of the category you want, and all other goods from this category will be enabled to load as well. That's the only way it works.

Well, I wouldn't guess :) Thanks, it works...