1) get the sdk zip from http://download.eurotrucksimulator2.com/scs_sdk_1_9.zip (it is not so easy to find just by googling)
2) unpack and simply type 'make' in the example dir of your choice (I chose telemetry_position). result s/b a .so file.
3) locate the directory in which your game executable really lives. I have the Steam version which means that my dir path is lengthy:
Code: Select all
/Users/USERNAME/Library/Application Support/Steam/steamapps/common/Euro Truck Simulator 2/Euro Truck Simulator 2.app/Contents/MacOS/
5) copy the .so to the plugins dir (modify the makefile to add an install target so you don't have to type that horrible long dir path ever again!)
6) now start the game. you should get a popup dialogue during startup that warns you about invoking advanced SDK features
7) if you look in the game_log and search for ".so" you should see a line confirming loading of your installed plugin
8) the telemetry_position plugin writes a log file with the X;Y;Z game coordinates of the driver's head, on a very frequent basis (per frame I think from reading the doco). the path of this logfile is unspecified in the fopen command in the source, which can make it a challenge to find the output file. I expected it to be in the same ETS2 library dir with the game log file, profiles, mod dir etc. it is not. it is in the same directory where you created the plugins dir, the directory where your game binary lives. if you want to put it somewhere else, like /tmp, just edit this line in the source .cpp:
Code: Select all
log_file = fopen("telemetry_position.log", "wt");
10) If you want to instrument and debug your plugin-in-progress, the Q&D way is a call to game_log, which is made accessible early in the plugin init function scs_telemetry_init. I have so far identified 2 levels of log message, _warning and _error. Presumably there is a harmless info level but I haven't tried empirically discovering its name yet and have not so far found any programmer's reference that documents basic functions of this kind. game_log will write to the game_log.txt file and to the dev con (when visible), so it's very handy.
11) you can edit and retry your plugin without shutting down the game. the command 'sdk reload' from the dev con should reload all plugins. I believe that 'sdk reinit' will restart the plugin without reloading it, but I haven't verified this yet. reload would be useful (as the readme points out) if you have made your plugin depend on a config file for its initial state.
My impression is that the API is still at a pretty technical level, i.e. no one has yet written a higher-level library to simplify access to the telemetry data. I don't think my C coding skills are quite up to that, but if I do produce anything useful along those lines I'll share. If anyone else is working on telemetry for OSX/linux please keep in touch And if anyone knows how game coords map to reality (i.e. to game km, which I guess map to real-world km by way of local scale) I would really like to know this!
My goal is a generic telemetry data server using UDP datagrams, with keyword based data request; I'd like to end up with a plugin that starts at run time, monitors all the available data, and serves it to any connected client on request. There's a lot of code between me and that goal, and it's going to be hard slogging with my primitive C coding chops -- so if anyone from OSX/Unix land feels like helping I'd be very happy to set up a github project and collaborate, or join in an existing effort.