My (grid-structured) base is getting larger and larger, and I have trouble keeping up with the trains (>3700) and the available train stations (>2250). Now and then I want to know which stations need more trains assigned, or where supply is not keeping up etc. The available list in factorio is working rather well, but it's quite cumbersome to scroll through all stations and comparing data manually.
So, my idea is to export some data to json periodically. The json-files can be fed to some external (custom) tool and there I can extract/display the data I need, point out bottlenecks etc. As a start I created a (very, very) simple mod which now only exports the active entity count, just as a start.
Code: Select all
local json = require "lib/json"
local default_export_file = "export.json"
local function onExportCommand(event)
local output = {}
output.active_entities_count = game.get_active_entities_count()
local file = event.parameter or default_export_file
game.remove_path(file)
game.write_file(file, json.encode(output), true)
game.players[event.player_index].print("Export successful")
end
commands.add_command("export", nil, onExportCommand)
Code: Select all
{"get_active_entities_count":120949}
Now for starters, I would like to have a list of all stations (grouped by name) and the amount of trains, just as in the train overview within the game. E.g.
- Copper cable [150] 300/300
- Copper cable ore [69] 123/136
I've searched through these forums a bit, but I cannot find how to do this (and lua is new to me too). Do I have to use the game.get_train_stops() reference?
Any suggestions on how to do this?
Thanks in advance!