From Tiled to Tome and into the game


Overview & information


This tutorial is about exporting data from Tiled and importing it to Tome.
There are three methods for exporting data regarding any edited or newly created cities and productions (and their settings) and importing them into Tome:

1.) Using our Excel documents
2.) Create yourself a similar spreadsheet
3.) Do everything manually

The goal of all three methods is to import the *.tmx file into a spreadsheet application, rearrange the data and export it as a *.csv file. This will enable you to import everything into Tome (as you can export the necessary *.ini files from there as the required by the game in order to work with your customised content).

The first method is the quickest, but might only work with Excel 2013 using the German language. This is, because Microsoft Excel needs the input of formulas in the native language of the user‘ operating system and unfortunately, we had to use a German Office version for creating those files. However, a quick internet search will bring up web based tools for translating formulas from German to another language and you should be able to adjust the Excel files if you want to. The files are called tmx2Towns.xlsx and tmx2ProductionSites.xlsx and they are located in the following directory: \Documents\My Games\Railway Empire\ugc\shared\import

The second method is to build yourself a similar tool as mentioned above, maybe even with a different spreadsheet tool.

The third method is to adjust everything you might have changed in Tiled in Tome manually. This is the least recommended method, as the possibility for mistakes is the greatest for this non-automated solution.


What is in the Excel file(s)? or How to set up the spreadsheet?


The chapters below will give you more detailed information about every single tab. In this chapter, there is only short summery. Here are the tabs and their intended usage:

ImportThis is for importing the desired *.tmx file. You can handle it just like any *.xml file
GetCitiesThis is for gathering all information about cities
GitGudThis is for gathering all information about rural businesses
Results (for cities)This will be the area to format the desired data about the cities and their settings for export
Results (for productions)This will be the area to format the desired data about the productions and their settings for export
Material (only needed for productions)This will be the area to list the required strings for the ProductionSiteTypeNameId
(more information under "Productions: How to get the required information from the Imports-tab?")
How2 (not necessary)This will be the area to note some general information about proper usage of the file


Imports


The first cell of each line contains the corresponding line of the *.tmx file. So, the number of lines in this tab of the spreadsheet should equal the number of lines of your *.tmx file when opened in any text editor.


Using the existing Excel file


When using the provided Excel files an import dialogue will pop up asking you for a file – here, set the file type to “All files (*.*)” and select any *.tmx file. That way, the data will be imported and should already have the right format. If you did so and no error message popped up, you can skip everything in this tutorial up to “Is there a way to validate that everything is correctly exported to the *.csv file or Tome?” if you are working on cities and skip everything up to “Cities: Is there a way to validate that everything is correctly exported to the *.csv file or Tome?” if you are working on the rural businesses and then go to “After exporting, what to do in order to get my changes into the game? ”.


Cities: GetCities


The GetCities tab gathers the information needed from the Imports tab and will prepare the data for a smooth export in the Results (cities) tab. A full list explaining the single parameters can be found in the Glossary.


Cities: How to get the required information from the Imports tab?


To really understand what you are going to do here, you should have a closer look at the *.tmx files – maybe with a simple text editor. You’ll notice patterns in which the cities are implemented here. For a good start, I’d recommend to find out the first line. For example, this can be achieved by looking for something like „ <objectgroup name=““city_*“ within the first column. As soon as you got the number of the first instance of that occurrence you can build up on that.
From there, you can take advantage of the rather fixed structure of the *.tmx file and can extract the ID (and re-arrange it into the DisplayName), TownFounded, TownFactory0 to TownFactory2 and TownPopulation values. A full list explaining the single parameters can be found in the Glossary.
After you managed to gather all the data of the first city in your first line it will get a little tricky, because you need to find the second instance of a city. A way to do that could be to reuse the formula used for finding the first occurrence of a city and add a little part to it that adds the line number of the first occurrence of a city to the to the first line you are starting you search for the second occurrence of a city – that way it should work just fine. In addition, I only can recommend to implement something to each formula to intercept any possible errors – you will notice that it will prevent errors later on while exporting.


Cities: Is there a way to validate that everything is correctly exported to the *.csv file or Tome?


Yes, you can have a look at it in two different spots: The exported *.csv file and within Tome.
For the first method, you can have a look at any „tmx2Towns.csv“ file located within any of your scenario folders, because they should represent a correctly exported state of the default state of the corresponding level. For the second method, you can import the *.csv file within Tome and have a look at its Output window. If everything is done correctly, the last line in the Output window could look like this:
Import finished. 0 new records added. 6 field values updated, 40 skipped, 134 up-to-date.


Cities: Results


This is basically the place to get the data ready for export.
The first line must contain the definitions mentioned above (ID; DisplayName; NameId; TownFounded; TownActive; TownFactory0; TownFactory1; TownFactory2; TownPopulation).
The lines below will list the corresponding data with a single line for each city. After you managed to have a complete list of all cities you have to export (only) this tab as a *.csv file with a “;” as separator. An example *.csv file can be found within any of your scenario folders and it is named “tmx2Towns.csv”.


Productions: GitGud


This is basically the same as it is for the GetCities tab. The GitGud tab gathers the information needed from the Imports tab and will prepare the data for a smooth export in the Results (productions) tab. A full list explaining the single parameters can be found in the Glossary.


Productions: How to get the required information from the Imports tab?


Same procedure as used for the GetCities tab. Have a closer look at the *.tmx files – maybe with a simple text editor. You’ll notice patterns in which the cities are implemented here. For a good start, I’d recommend to find out the first line. For example, this can be achieved by looking for something like „ <objectgroup name=““pro_*“ within the first column. As soon as you got the number of the first instance of that occurrence you can build up on that.
From there, you can take advantage of the rather fixed structure of the *.tmx file and can extract the ID (and re-arrange it into the DisplayName), ProductionSiteFactory and SiteStatus values. The NameId value can be generated by chaining up “ID_NAME_LAND_” with a sequencing consecutive numbering starting with “00”. For generating valid values for the ProductionSiteTypeNameId you have to know what production is of what type. A full list explaining the single parameters can be found in the Glossary.
After you managed to gather all the data of the first production in your first line it will get a little tricky, because you need to find the second instance of a production. A way to do that could be to reuse the formula used for finding the first occurrence of a production and add a little part to it that adds the line number of the first occurrence of a city to the to the first line you are starting you search for the second occurrence of a production – that way it should work just fine. In addition, I only can recommend to implement something to each formula to intercept any possible errors – you will notice that it will prevent errors later on while exporting.


Productions: Is there a way to validate that everything is correctly exported to the *.csv file or Tome?


Yes, you can have a look at it in two different spots: The exported *.csv file and within Tome.
For the first method, you can have a look at any „tmx2ProductionSites.csv“ file located within any of your scenario folders, because they should represent a correctly exported state of the default state of the corresponding level. For the second method, you can import the *.csv file within Tome and have a look at its Output window. If everything is done correctly, the last line in the Output window could look like this:
Import finished. 0 new records added. 3 field values updated, 122 skipped, 241 up-to-date.


Productions: Results


This is basically the place to get the data ready for export.
The first line must contain the definitions mentioned above (ID; DisplayName; NameId; ProductionSiteFactory; SiteStatus; ProductionSiteTypeNameId).
The lines below will list the corresponding data with a single line for each production. After you managed to have a complete list of all productions you have to export (only) this tab as a *.csv file with a “;” as separator. An example *.csv file can be found within any of your scenario folders and name it “tmx2ProductionSites.csv”.


After exporting, what to do in order to get my changes into the game?


Therefore, you will need to open Tome and (if you haven’t already done this) add the *.timport files which can be found in any of your scenarios. There are the template files for importing your custom settings saved to *.csv files called Import “ProductionSites (CSV).timport” and “Import Towns (CSV).timport”. You can enable Tome to import *.csv files by using the following method:
Projects -> Project Overview… -> Import Templates -> Add Existing (they are located in \Documents\My Games\Railway Empire\ugc\shared\import)

After a successful import the output of Tome should give you feedback about how many entries have been added or changed. Now, you can export the corresponding *.ini file.

  • The method for exporting the cities is: Export -> Town INI (file created is called “town.ini”)
  • The method for exporting the productions is: Export -> ProductionSite INI (file created is called “productionsite.ini”)