The International Simutrans Forum

 

Author Topic: [TUTORIAL] Creating an addon (I): Introduction  (Read 9563 times)

0 Members and 1 Guest are viewing this topic.

Offline vilvoh

  • One of the good guys
  • Administrator (Inactive)
  • *
  • Posts: 4504
  • I'm the constructor, the architect
    • Escala real
[TUTORIAL] Creating an addon (I): Introduction
« on: September 06, 2009, 06:10:30 PM »
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

« Last Edit: September 09, 2009, 05:53:06 PM by vilvoh »

Offline edson

  • *
  • Posts: 381
  • Languages: PT, EN
Re: [TUTORIAL] Creating an addon (I): Introduction
« Reply #1 on: September 06, 2009, 06:18:41 PM »
This was not translated!  ;)
3.1. What does a pak file contain?
Um arquivo pak nada mais é que uma junção de dois arquivos:

Offline vilvoh

  • One of the good guys
  • Administrator (Inactive)
  • *
  • Posts: 4504
  • I'm the constructor, the architect
    • Escala real
Re: [TUTORIAL] Creating an addon (I): Introduction
« Reply #2 on: September 06, 2009, 06:29:16 PM »
Opsss!! don't blame me.. it's copy-and-paste fault!  :P

Offline edson

  • *
  • Posts: 381
  • Languages: PT, EN
Re: [TUTORIAL] Creating an addon (I): Introduction
« Reply #3 on: September 06, 2009, 06:32:51 PM »

leski

  • Guest
Re: [TUTORIAL] Creating an addon (I): Introduction
« Reply #4 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? For instance, the FREIGHT parameter - the general, multifreight values, elsewehere claimed to be named CATEGORY_01 through CATEGORY_06, actually make the game crash.

Offline The Hood

  • Devotee
  • *
  • Posts: 2889
  • pak128.Britain developer
Re: [TUTORIAL] Creating an addon (I): Introduction
« Reply #5 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).

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

Offline vilvoh

  • One of the good guys
  • Administrator (Inactive)
  • *
  • Posts: 4504
  • I'm the constructor, the architect
    • Escala real
Re: [TUTORIAL] Creating an addon (I): Introduction
« Reply #6 on: November 14, 2009, 06:00:05 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

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

leski

  • Guest
Re: [TUTORIAL] Creating an addon (I): Introduction
« Reply #7 on: November 14, 2009, 08:13:45 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 :)



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?

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 :)

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? ;)
« Last Edit: November 14, 2009, 08:26:20 PM by IgorTekton »

Offline DirrrtyDirk

  • Devotees (Inactive)
  • *
  • Posts: 1253
  • JR 700 Series Shinkansen
  • Languages: EN,DE
Re: [TUTORIAL] Creating an addon (I): Introduction
« Reply #8 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.

leski

  • Guest
Re: [TUTORIAL] Creating an addon (I): Introduction
« Reply #9 on: November 15, 2009, 01:21:09 AM »
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...