1 CommonAPI2 quickstart guide
Deutsche Version: CommonAPI2 Schnelleinstieg
CommonAPI2 is build in two parts:
- A normal script - mod
- Binary “native” part (dll for windows, so library for linux)
With binary native part it’s possible to modify the game memory and change the game at low level to add new stuff to the game. This part has to match the game version.
2 Is CommonAP2 loaded?
The binary native part will be loaded as soon as the mod is installed.
At the top left corner there will be a CommonAPI2 menu as soon as the main menu is shown.
Additional api functionality for other mods and in-game addons are only fully active if commonapi2 is loaded in the savegame mod list.
It’s only possible to install one version of CommonAPI.
If you don’t subscribe to the steam version, you have to install CommonAPI2 into the mods folder of the game.
The folder has to be named eis_os_commonapi2_1, otherwise commonapi2 will not work correctly. The zip provides always the right folder name!
Subscribing to the steam version and local installation won’t work!
For testing if you think the native part (dll or so) creates a crash, it’s possible to temporary disable commonapi2 native part via commonapi2 settings.
Disabling the native part can create several problems and loading times increase. If you think you can’t use the native part, it is strongly recommend to uninstall or unsubscribe!
If you you have problems, please leave a bug report, otherwise errors can’t be fixed.
The mod download and upgrade function needs curl. (curl will be provided by Windows 10 1803 or later)
7-zip is required for mod extracting and upgrade: https://www.7-zip.org/
Requires curl and p7zip-full, see you package manager.
- Line (train) destination display
- API for mod authors
- Lua console on all LUA states
- Changing mod settings (settings.lua)
- Mod list export and importt
- Check for new mod versions on transportfever.net
- Upgrade mods from transportfever.net
4.1 Line Destination display
Currently there is only a German description for LINE_DESTINATION:
4.2 CommonAPI menu
The commonapi menu can be toggled via right Alt + C ein.
Several functions can be reached here:
Directly open the installation and local user folder of the game .
4.2.2 Lua Console
The lua console shows the last stdout.txt messages and predates UGs lua console.
Directly send lua statements to all lua states of the game (commonapi2 has to be in the game mod list)
Drop down list to switch between lua states / threads of the game
If you want to dump some information, you can use commonapi.dmp(<variable>)
4.2.3 Mod settings
Mods may have setting via settings.lua, this system predates UGs mod settings system. Actually it was introduced by TPFMM and used already in Transport Fever 1
As soon as there are list of mods provided via advanced game settings, it's possible to change mod settings and to load and save a mod list.
Changes while in game a usually not possible, there are only a few mods that reload their settings.lua in game.
Mod upgrades are not possible in game or in savegame loading mode, you have to go back to the main menu so TPF2 reloads the mods on disk!
Mods can support dependencies and commonapi2 will show warnings if the mod is missing or not loaded.
4.3 Modlist export & import
As soon as there are list of mods provided via advanced game settings, it's possible to export list of all active mods and or import a list.
Example: Select an old savagame, go to advanced game setting without starting the savegame, then it's possible to export the modlist.
In main menu -> Free map -> next -> clicking settings in the create new game window (top right) -> Advanced game settings window opens
Now open commonapi mods menu, import mod list...
5 Different versions
Currently the steam version has no functionality because the game crashes badly when using TPF2 ui toolkit.
Technical the download section on transportfever.net has always a stable version. On the forum there may be development versions.
There is no difference between Steam and GOG Versions, however only Windows and Linux is supported.
Technical it's not possible to provide a mac version. I don't own the epic games store version, so it may work via build overwrite.
6.1 TPF2 Build not supported, error message on the main menu, using build overwrite
Sometimes Transport Fever 2 get new updates (builds)
In the forum I will post information about compatibly to the new TPF2 build and how to enable commonap2 to work with a certain game build via build overwrite. (Steam, GOG, Windows and Linux)
Please follow this link and look at the last message CommonAPI2 - Neue Versionen und wichtige Informationen
6.2 buildoverwrite step by step guide
- Click on the red error message in main menu
- The commonap2 emergency settings window appears.
- Scroll down until you can change Build overwrite
- Insert the right build overwrite string as mentioned on the forum (to get a cursor, simple click in the small text window)
I will provide the necessary string for tested versions
- Click on save, close the window then close the game.* On Linux the emergency windows build with the TPF2 toolkit may hang the game, please kill the TransportFever2 task, the reason there is no steam release currently!
- After a game restart you should see the commonapi2 menu again. If you get an error about the native part is disabled, please check your settings, you have enabled/checked disable native library extension!