Simple OpenTTD GameScript HTTP Binding and Game Logger with a Flask Microservice.
Have you ever found OpenTTD's in-game stats to be insufficient and inaccessible? This piece of software aims to fix that. Stats are collected continuously, and saved to a database of your choice. Stats are are also accessible via HTTP endpoints.
- OpenTTD + OpenTTD Source for your installed version
- ServerGS (internet-trains fork)
- A Python 3.7+ installation (for running Flask Service + Generating Bindings)
- (optional) A Database (supported)
- Edit
gen_api_binding.py
- Set
openttd_path
to your openttd path (/Users/ian/Downloads/OpenTTD-patches-jgrpp-0.34.3
for me) - Set
gs_path
to your gamescript folder path (src/script/api/game
for me) - Set
version
to your version (string).
- Set
- Run
gen_api_binding.py
with your python installation. - Copy the enclosing folder to your gamescript folder path.
- Run
python3 -m pip install -r requirements.txt
- Set your
SQLALCHEMY_DATABASE_URI
environment variable to your db's uri. - Run the following commands.
export FLASK_APP=ottd.py
python3 -m flask db init
python3 -m flask db upgrade
python3 -m ./gen_doc.py
Optional, if you wish to use something other than an SqliteDb:
export DATABASE_URL=YOUR_DATABASE_URI
Then run
export FLASK_APP=ottd.py
export OTTD_GS_HOST=127.0.0.1
export OTTD_GS_PORT=3977
export OTTD_GS_PASSWORD=password
python3 -m flask run -p 5000
Doc is hosted at http://localhost:5000/swagger-ui
or http://localhost:5000/redoc
when the server
is running. api.json
can also be used with other OpenAPI doc tools.