Games::Simutrans::Pakset - Represents an entire Pakset for the Simutrans game


version 0.01


  use Games::Simutrans::Pakset;

  my $g= Games::Simutrans::Pakset->new;

  use Data::Dumper;
  print Dumper($g->languages);


  print $g->object('4-wheel-1850s')->to_string;


Games::Simutrans::Pakset creates objects that represent a Pakset for the Simutrans game. These objects are of type Games::Simutrans::Pak, and are accompanied by various other meta-information like language translations.

"Each pakset has different objects, buying prices, maintenance costs, themes and a whole unique gameplay. Every pakset is a new game." --

Component objects created represent language translations, graphical objects, and so on. As yet the representation in the objects created by the Perl modules are incomplete, but eventually they may be enough to load a pakset into a game engine written entirely in Perl, or to permit editing an entire Pakset while enforcing set-wide consistency (i.e., timelines will not include eras when no rail vehicles are unbuildable; goods prices or capacity and motive power growth can be tracked over time, etc.)

Paksets for both the Standard and Extended (formerly "Experimental") versions for Simutrans are supported.



  my $pakset = Games::Simutrans::Pakset->new;

Create a new Pakset object. This module uses objects contructed with Mojo::Base. The following attributes, all optional, may be useful to pass when creating the object:



An identifying name for the pakset. Not used in any computation; as an identifier only.


Returns, or sets if an argument is given, the base path on the local filesystem for the pakset root. Tildes are expanded to the user's home directory. After tke pakset is loaded, this will be a Mojo::File object (which, when used in scalar context, reduces to the path string).


Returns a nonzero value if the path() appears to contain a valid Simutrans pakset. At the moment it simply verifies that the path exists.


Returns, or sets if an argument is given, the base path, usually a subtree under that pakset root, where the language translation files are stored.


Returns a Mojo::Collection of available language translations, based on the directories and files that exist in xlat_root.


Returns, or sets if an argument is given, the current language for translation. Defaults to the environment string LANGUAGE, or LANG, or en otherwise.

translate ($string, $language)

Returns the translation of $string in the $language given (or in the current language if $language is undef).


Returns the actual language translation tables, as used by the translate method.


Returns a hash of all the objects defined in the pakset.


  my $obj = $pakset->object($object_name);
  my $attr = $pakset->object($object_name, $attribute);
  $pakset->object($object_name, $attribute, $value);

Returns a hash of the values for the given object, by name. If $attribute is set, returns only that attribute (which may be a scalar, array, or hash) or sets it (if $value is defined).


Returns a hash of discovered image files for the Simutrans objects in the pakset. The keys of the hash are the full ocal pathnames of the files, with each value being the matching Games::Simutrans::Image object.


  my @objects = $pakset->grep( sub { ... } );

Calls the callback, using List::Util::pairgrep, once for each item in the hash of attributes for each object (the two parameters to the callback being the object name, and its hash of attributes). Returns a list of object names for which the callback returned a nonzero value.


  my @obj_types = $pakset->objects_types;

Returns a list of object types defined in the pakset.


  my @obj = $pakset->objects_of_type('vehicle');

Returns a list of the objects of a given type as defined in the pakset.


  my $timeline = $pakset->timeline($type);

Returns a timeline, in chronological order, of the introduction and retirement dates for each object in the pak, or for objects of the type given.



Saves an attribute hash in the pakset. The attribute name must contain the object name, which will become its key in the pakset's object hash.



Reads a single *.dat file using Mojo::File::slurp, splits it into individual objects (separated by lines beginning with at least two dashes, as per the *.dat specification), calls the from_string method in Games::Simutrans::Pak to create a Pak object from it, and then the save method in this module to save that Pak in the Pakset object.



Loads an entire pakset, from the path given or from the path at the path attribute.


Returns a Mojo::Collection list of all the *.dat files loaded via the load() method.


For each of the various graphic subimages defined in the pakset, determines in which actual *.png file they are contained, and finds the maximum (x,y) grid locations used in each *.png file.


Actually loads (using the Imager module) each *.png file which is called for by the pakset, and using the maximum (x,y) grid locations discovered by find_all_images, determines the tile size for each *.png file.


Loads the "convoi" livery files using Games::Simutrans::Livery and keeps track of the period of use of each of them.


Returns a hash, keyed by the name of each livery, of pertinent data.


William Lindley <>


Copyright 2021 William Lindley


This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


Games::Simutrans::Pak, Games::Simutrans::Image, Games::Simutrans::Livery


Simutrans,, is a free-software, open-source transportation simulator.

The Simutrans Wiki,, explains the format of *.dat files. They are normally fed, along with graphic *.png files, to the makeobj program to make the binary *.dat files that the Simutrans game engines use.