Hi all,
I'd like to make some analysis/data visualization for OpenTTD data. At the moment it looks to me like the best option would be to get a kind of events happening in it (like train #n stopped at the station $station_name; train #n unloaded $cargo_name for $dollars; factory $factory_name has increased output to $value, etc). Or the other suitable option is to have an API and poll it periodically for changes.
Correct me if I wrong, but it seems to me that NoAI and Game Scripts frameworks have only access to non-player objects.
Is there anything like that available? I don't think I can build it inside of OpenTTD so I'm looking for a way to get the data outside of it.
Is there any API for user's vehicles, stations, routes, etc.?
Moderator: OpenTTD Developers
- orudge
- Administrator
- Posts: 25137
- Joined: 26 Jan 2001 20:18
- Skype: orudge
- Location: Banchory, UK
- Contact:
Re: Is there any API for user's vehicles, stations, routes, etc.?
I think if you're wanting to hook into a live game, the best way to do so is via a multiplayer server. JOAN (Java OpenTTD Admin Library) seems to be the most complete project that does this. There's also an older Python project available.
If you're just wanting to interrogate a saved game, I started work on a C# library to do this some years ago - it's a bit stuck in limbo but one day I will hopefully release it (although it may not be complete!)
If you're just wanting to interrogate a saved game, I started work on a C# library to do this some years ago - it's a bit stuck in limbo but one day I will hopefully release it (although it may not be complete!)
Re: Is there any API for user's vehicles, stations, routes, etc.?
Thanks for the hint. Both libraries look a bit undocumented to me but connecting to (or maybe emulating?) a network server looks like a good idea to start with.
-
- Engineer
- Posts: 26
- Joined: 20 Dec 2017 17:56
Re: Is there any API for user's vehicles, stations, routes, etc.?
I would expect that doing it from within OpenTTD would be by far the easiest way to do it.Andrew_if wrote:Is there anything like that available? I don't think I can build it inside of OpenTTD so I'm looking for a way to get the data outside of it.
Events like trains stopping at stations, cargo unloading, etc. are not directly recorded in savegames after the fact, and are not transmitted as part of the multiplayer protocol.
Each multiplayer client runs a full game simulation separately.
Adding some printf lines to key functions in the source, recompiling, running it, and then analysing the output is probably your best bet.
Ex TTDPatch Coder
Patch Pack, Github
Patch Pack, Github
Re: Is there any API for user's vehicles, stations, routes, etc.?
By "outside" I mean that my data viz project won't be a part of the game. At the moment I'm thinking about a streaming engine like Apache Kafka plus Grafana as a front-end. Maybe a kind of database in between. I hope it will be interesting/useful not only for me but don't know if it possible at all and if I can do it simple and reproducible. The question is if I can feed this system with data.JGR wrote:I would expect that doing it from within OpenTTD would be by far the easiest way to do it.Andrew_if wrote:Is there anything like that available? I don't think I can build it inside of OpenTTD so I'm looking for a way to get the data outside of it.
Who is online
Users browsing this forum: No registered users and 25 guests