Transport Fever 2

Transport Fever 2

Statistics++
RadiKyle 3 May, 2024 @ 7:37am
Feedback / issues / questions (was: Cargo?)
Wow looking forward to checking this mod out! Ever since the "More Line & Station Infos" mod became a crashfest after the March 2023 game update (and seems to be abandoned), we've been hurting for detailed line stats.

In your screenshots and description I only see passengers mentioned, is cargo included as well? I mean for destination info for cargo lines (similar to the above mod).
Thanks
Last edited by RadiKyle; 3 May, 2024 @ 12:35pm
< >
Showing 1-15 of 28 comments
RadiKyle 3 May, 2024 @ 8:33am 
...Okay testing it now in a vanilla testbed and can see cargo destination info is not included.

Here's some observations for early feedback. Depending on your intent some of these may not be important.

1. Towns tab (global), clicked eye icon on a town, window opened nearly off the right side of the screen. Depending on screen res some users might not see it at all?

2. Towns tab (global), hover popup shows Average Speed on the Car Ownership column, should it be on the Traffic Speed column instead?

3. Town window, live stats are blank (sim is unpaused).

4. All table headings could use descriptive popup (for example Total Rep and Transit Rep in town window has some crazy percentages like 842% and 1059%).

5. Stations tab (global), is it possible to group these by town, especially since there are many repeated names?

6. Stations tab (global), opened a station using eye icon, closed it, can't re-open (it's greyed out) unless I click Refresh button first. Expected?

7. Stations tab (global), opened a station showing 0 passengers, station window shows non-zero passengers with destinations etc. Are these recently departed passengers that are still en route to destination?

8. Station window, Waiting Passengers section is blank (and there are waiting pax at the station).

9. Lines tab (global), Show All selected, always blank even after Refresh.

10. Lines tab (global), any vehicle type filter selected, must click Refresh first. Some still remain blank (intermittent).

11. Lines tab (global), Ships selected, always blank even after Refresh. Changing to Within Circle works.

Hope that helps, cheers!
okeating  [developer] 4 May, 2024 @ 5:40am 
Many thanks for this feedback - it is very useful and I have gone through and tried to address all of these, will push an update shortly.

At the moment there is no cargo info, obtaining that requires a different set of api calls and I also think that it would want to be implemented a bit differently, i.e. only grouping by town where that is the end of production chain. If people think it would be helpful I may have a go at trying to implement it.

In response to your points:
1. This should now be fixed
2. I have update the tooltip to clarify this refers to owned vehicle maximum speeds
3. This was not implemented, I have now removed it from the display
4. Agreed, I have added tooltips to that table and am looking at others where it is not obvious
5. Grouping by town is probably quite a lot of work, for now I have changed it to sort by waiting numbers as those are probably the stations of interest
6. Unfortunately yes, at the moment there is no "refresh" functionality in this screen so this is actually needed to update the stats
7. Related to above the data is read only on demand so it may become stale as the game progresses
8. Similar to 7.
9. This should now be fixed
10. The "change filter" is now plumbed into the refresh so this should now be fixed
11. Could not replicate / may now be fixed by change in 10.

Many thanks, keep the feedback coming!
RadiKyle 4 May, 2024 @ 12:00pm 
Hi, thanks so much for the update, it's made a big difference!

For #4 (the table headings), some of the table heading info popups in the town windows might have some typos. For example the Private columns mention transit.

Adding some table heading info popups in the main window Town tab would be great too.


For #5, whether we sort by name or passenger (or cargo) amount or whatever (would be great if these columns are made user-sortable), it can still be challenging to find a specific station in the list. Like this window is great for opening the stats of a station while viewing the list, but if instead we're just browsing the map and want to know the stats for a random station we see, there is no quick way to access it. Is it possible to make the station windows accessible from the vanilla station windows? That way we can click on a station and then click something to get the extra stats for that station. (This is similar to how the now-broken More Line & Station Infos mod worked.)


For #8, sorry I actually meant the bottom Waiting Passengers section is blank ("grouped by origination"). But I see now that it depends on which station I look at. A station can have passengers but the bottom section can be blank.

I'm still trying to understand what stats are shown here. It seems that not all of the passengers in a station window are actually waiting at that station, some seem to be passengers waiting at *other* stations to come to this station. It seems counter-intuitive compared to the vanilla station windows, so I'm wondering if the section labels can be made more clear to avoid confusion?

The only section that seems to refer exclusively to passengers at *this* station is the middle one, "...grouped by next dest...". So maybe something like "Outbound pax waiting at this station"?

The bottom section seems to refer to pax waiting at *other* stations to come to this one, so maybe "Inbound pax waiting at other stations"?

The top section I haven't been able to figure yet. Should "City 1 / 2" be "Source / Destination" for clarity? And where are these passengers, because they don't seem to be at this station?(hundreds more than present at this station.)

This screenshot shows example game I'm testing, and I can't figure out the stats.
https://imgur.com/a/iFYhQuX
(It's 3 cities connected by 2 separate rail lines with simple A<>B and B<>C connections, with Norwalk as the B "hub"). I have all the vanilla and stats windows open for the 3 stations. I haven't figured out the top section at all.

The middle section makes sense (it's the closest to vanilla since it's only about passengers actually present at the station).

The bottom one kinda makes sense except for the origination info. I think some confusion for me may be I'm not understanding what origination and destination means. Is it for a single one-way trip? Or for a round-trip, where the origin and destination are actually the same and it disregards where the person actually went in between? For example Norwalk shows the 220 pax waiting at Corona, with 116 coming from Norwalk so apparently returning home, and 104 coming from Frement, so also returning home. But where are the pax that live in Corona that are leaving to visit Norwalk? The top section suggests there are 115 of them, so why are they not in the bottom section.

Ok I guess I'm just thoroughly confused...


Anyhow I'm also I'm seeing a station name mis-match, the windows say "Norwalk Branch" but no such station name exists in the game, and it seems to be referring to "Lower Norwalk" instead. Is it somehow accessing former station names?


For #9 and 10 (global), it works now for Bus and Tram, clicking the filter automatically shows the list without needing to click refresh. But Show All, Rail, and Sea aren't working at all, they remain blank regardless of whether I click Refresh. They only appear if I switch from Global to Within Circle.


Regarding cargo, yes it's very much something that would be great to see. Passengers are interesting but I rarely spend time debugging passengers, they kind of take care of themselves since they automatically choose where to go. (And as seen above, keeping track of the origin/destination can be really confusing.) Cargo however must be managed and when it goes wrong bad things happen to the network, so I find extra cargo stats really useful. It would be great if the modder of More Line & Station Infos could fix whatever broke in that March 2023 game update because it worked really well before that, but it seems they've moved on to other things. Fixing that mod, or maybe reviving its functions here in this mod, would be great.


Thanks again, sorry for the wall of text, hopefully it's helpful somehow. If you want the savegame I'm using for testing, just point me to a dropbox or something where I can upload it.
Cheers
Last edited by RadiKyle; 4 May, 2024 @ 12:05pm
okeating  [developer] 6 May, 2024 @ 5:19am 
Hello, thanks again for your message - I will look into making some more updates shortly.

RE: #5 - the "within circle" is intended to take care of this, i.e. it will only list the stations currently visible

RE: Station name mismatch - I have no idea why this happens, I am pulling data from the TPF2 api so it is not clear to me why this is happening. It might be related to station group logic. I will have a look.

RE: Source
When I had first wanted to implement this I had intended to see where the passengers are coming from, i.e. for every passenger how are they using a particular station for their journey, i.e. where are they coming from and where is their eventual destination.

Unfortunately the API does not provide this information. It only gives their "next station" and their "target destination". There is no information about where they are coming from.

To try to get some information out I did a couple of things:
- examine all waiting passengers with the "next stop" as the selected station
- infer their original source to be their residence if they are currently travelling to a commerical/industrial zone.
- if they are making a return trip it will fall back to having their source as whatever station they are currently waiting at

I realise this is not perfect but I have found in practice it gives enough information to work out if a direct link between two (indirectly) linked cities is worthwhile (and eases congestion).

In the past I did use the "More line and station infos" mod, but I found the breakdown a bit too granular as to where they were going - I really just wanted a grouping by city, the breakdown of residential/commercial etc. was superfluous.

Also that mod works by recording data, which has its pros and cons. If done correctly it can give a more accurate picture (vs the "snapshot" approach I use), but the additional code required to execute every few simulation frames may impact performance and stability.

That said, this mod does to some "recording", such as the line detail panel where the section load information will become progressively more accurate as samples are taken. It only does this, however, while the panel is actually open.
RadiKyle 6 May, 2024 @ 8:21am 
Originally posted by okeating:
Unfortunately the API does not provide this information. It only gives their "next station" and their "target destination". There is no information about where they are coming from.

To try to get some information out I did a couple of things:
- examine all waiting passengers with the "next stop" as the selected station
- infer their original source to be their residence if they are currently travelling to a commerical/industrial zone.
- if they are making a return trip it will fall back to having their source as whatever station they are currently waiting at

I realise this is not perfect but I have found in practice it gives enough information to work out if a direct link between two (indirectly) linked cities is worthwhile (and eases congestion).

Ah! Ok that probably explains why some of the stats don't seem to add up. Knowing that the true origins are unknown might help me better understand what it's showing. I'll study it some more...

You say you examine waiting pax based on next stop, do you also do it with target destination? Or does target destination mean an RCI bldg instead of a station? Does target destination allow you to extract a city's name?


Originally posted by okeating:
Also that mod works by recording data, which has its pros and cons. If done correctly it can give a more accurate picture (vs the "snapshot" approach I use), but the additional code required to execute every few simulation frames may impact performance and stability.

I wonder if that's why that mod started crashing after the March 2023 game update.
Last edited by RadiKyle; 6 May, 2024 @ 8:21am
Bill_Lestrange 11 May, 2024 @ 3:26am 
This is the error that I get when I try to interrogate any of the stations:
An error was caught C:/Program Files (x86)/Steam/steamapps/workshop/content/1066780/3238328414/res/scripts/statistics_station_detail_comp.lua:120: stack index 2, expected number, received nil: not a numeric type (bad argument into 'sol::basic_object<sol::basic_reference<0> >(sol::basic_table_core<0,sol::basic_reference<0> >, ecs::Entity, enum scripting::ComponentType, sol::this_state)')

stack traceback:
[string "C:/Program Files (x86)/Steam/steamapps/workshop/content/1066780/3238328414/res/config/game_script/statistics_script.lua"]:9: in function <[string "C:/Program Files (x86)/Steam/steamapps/workshop/content/1066780/3238328414/res/config/game_script/statistics_script.lua"]:7>
[C]: in function 'getComponent'
C:/Program Files (x86)/Steam/steamapps/workshop/content/1066780/3238328414/res/scripts/statistics_station_detail_comp.lua:120: in function 'lookupTownFromConstruction'
C:/Program Files (x86)/Steam/steamapps/workshop/content/1066780/3238328414/res/scripts/statistics_station_detail_comp.lua:138: in function 'openWindow'
C:/Program Files (x86)/Steam/steamapps/workshop/content/1066780/3238328414/res/scripts/statistics_station_panel.lua:164: in function <C:/Program Files (x86)/Steam/steamapps/workshop/content/1066780/3238328414/res/scripts/statistics_station_panel.lua:163>
[C]: in function 'xpcall'
[string "C:/Program Files (x86)/Steam/steamapps/workshop/content/1066780/3238328414/res/config/game_script/statistics_script.lua"]:193: in function <[string "C:/Program Files (x86)/Steam/steamapps/workshop/content/1066780/3238328414/res/config/game_script/statistics_script.lua"]:191>

When I try to get line info, I get the following:
An error was caught C:/Program Files (x86)/Steam/steamapps/workshop/content/1066780/3238328414/res/scripts/statistics_construction_util.lua:166: bad argument #1 to 'pairs' (table expected, got nil)

stack traceback:
[string "C:/Program Files (x86)/Steam/steamapps/workshop/content/1066780/3238328414/res/config/game_script/statistics_script.lua"]:9: in function <[string "C:/Program Files (x86)/Steam/steamapps/workshop/content/1066780/3238328414/res/config/game_script/statistics_script.lua"]:7>
[C]: in function 'pairs'
C:/Program Files (x86)/Steam/steamapps/workshop/content/1066780/3238328414/res/scripts/statistics_construction_util.lua:166: in function 'getStationLength'
C:/Program Files (x86)/Steam/steamapps/workshop/content/1066780/3238328414/res/scripts/statistics_line_panel.lua:463: in function 'getMinStationLength'
C:/Program Files (x86)/Steam/steamapps/workshop/content/1066780/3238328414/res/scripts/statistics_line_panel.lua:497: in function 'getLineParams'
C:/Program Files (x86)/Steam/steamapps/workshop/content/1066780/3238328414/res/scripts/statistics_line_panel.lua:1686: in function 'getLineReport'
C:/Program Files (x86)/Steam/steamapps/workshop/content/1066780/3238328414/res/scripts/statistics_line_panel.lua:2056: in function 'getLinesReport'
C:/Program Files (x86)/Steam/steamapps/workshop/content/1066780/3238328414/res/scripts/statistics_line_panel.lua:2384: in function <C:/Program Files (x86)/Steam/steamapps/workshop/content/1066780/3238328414/res/scripts/statistics_line_panel.lua:2378>
[C]: in function 'xpcall'
[string "C:/Program Files (x86)/Steam/steamapps/workshop/content/1066780/3238328414/res/config/game_script/statistics_script.lua"]:193: in function <[string "C:/Program Files (x86)/Steam/steamapps/workshop/content/1066780/3238328414/res/config/game_script/statistics_script.lua"]:191>

>

Might be worth looking into.

I do wonder if this because I have a) a massive network with nearly 200 trains and over 60 lines, and b) a lot of my stations are waaaay longer than the 320m max that this mod specifies. A lot of my trains are longer than 400m.

Both of these errors mean I get basically no info beyond what the game can tell me anyway. I get no info about destinations from cities or line usage or max/average speed line.
Last edited by Bill_Lestrange; 11 May, 2024 @ 3:28am
Bill_Lestrange 12 May, 2024 @ 4:08am 
So I've had a fiddle with this on a map with no mods installed - and lo and behold, it works fine. So, I've been systematically adding mods in until it breaks. So far, I have yet to find a conflict. So why it doesn't work on my large, developed map, is a mystery to me.

I've checked the usual suspects - mods like the timetable mod, enzojz's script mods etc. and no luck yet. It might be just one of those things that I will have to accept. It's a bit of a shame, cos I would love to be able to look into these stats for my big, developed map. But for now, I will have to live without.

I have 300 mods active on that map - it's quite likely that something in the order is causing it to give the "table expected, got nil" error, but for the life of me, I can't find it.
RadiKyle 6 Jul, 2024 @ 2:28pm 
Hi @okeating , really like the new charts in v1.1!!

The Lines tab (Global) still works only for Road and Tram filter settings, the others are all blank. They only work if I switch to Within Circle.
okeating  [developer] 7 Jul, 2024 @ 12:04pm 
Maybe if you can post a dropbox or equivalent with a save I could take a look?
RadiKyle 7 Jul, 2024 @ 12:49pm 
No prob, here's a mod-free save I use for testing this mod:
https://drive.google.com/drive/folders/1a3Sbs9qBFyfLT5h3qTXGmwkd59BZ0HA7?usp=sharing
Note it's an older save, but I don't know it that matters.
bottle 30 Sep, 2024 @ 1:55am 
Hi Similar to Bill the mod doesn't work with train lines for me. It works fine with other lines (bus, ship tested).

It's hit and miss with stations (bus/train/ship). Works with a few doesn't work with most. I can't find a consistent cause but it never works with stations with >50 waiting.
VacuumTube 23 Nov, 2024 @ 9:51am 
Hi, I just saw that you are using direct indexing of getComponent results such as
api.engine.getComponent(stationGroupId, api.type.ComponentType.NAME).name
This should be avoided as it leads to random crashes with a certain probability. The result should be stored in a local variable first.
bottle 13 Dec, 2024 @ 1:09pm 
@VacuumTube I think it's a different issue that is causing the exception: The stationGroupId may be -1 which will cause this method to throw an error.

Fix is


local stationGroupId = api.engine.system.stationGroupSystem.getStationGroup(stationId) local stationName = "" if -1 ~= stationGroupId then stationName = api.engine.getComponent(stationGroupId, api.type.ComponentType.NAME).name else -- Fall back on station Name stationName = api.engine.getComponent(stationId, api.type.ComponentType.NAME).name end
Last edited by bottle; 13 Dec, 2024 @ 1:14pm
VacuumTube 14 Dec, 2024 @ 7:21am 
I was not talking about a particular case. It's a general issue with C++ sol2 that can lead to random crashes, which are very ugly because you cant really track the source.

UG has admitted this behavior but I am not sure if they documented it somewhere. See for example: https://github.com/IncredibleHannes/TPF2-Timetables/issues/50
RadiKyle 14 Dec, 2024 @ 8:30am 
Originally posted by VacuumTube:
I was not talking about a particular case. It's a general issue with C++ sol2 that can lead to random crashes, which are very ugly because you cant really track the source.

UG has admitted this behavior but I am not sure if they documented it somewhere. See for example: https://github.com/IncredibleHannes/TPF2-Timetables/issues/50

Thanks for the link to the dev comments, very interesting!

@okeating also posted about this issue back in June:
https://steamhost.cn/steamcommunity_com/workshop/discussions/18446744073709551615/4409668873661713750/?appid=1066780

I think the dev example interesting:
It seems that the library we are using to interface with C++ (sol2) is not liking the following:

​local fatInstances = api.engine.getComponent(id, api.type.ComponentType.MODEL_INSTANCE_LIST).fatInstances

If you change that to:

local comp = api.engine.getComponent(id, api.type.ComponentType.MODEL_INSTANCE_LIST)
local fatInstances = comp.fatInstances

the problem should be fixed.

I wonder if there should be another substitution because there is still a nested api call there, so this instead?:

local modelInstance = api.type.ComponentType.MODEL_INSTANCE_LIST
local comp = api.engine.getComponent(id, modelInstance)
local fatInstances = comp.fatInstances

Edit: Ever since @okeating's PSA post in June I've been trying to wrap my lua newb brain around this, and currently treating it as every api call should be immediately stored in a local variable to be ultra safe. I think I don't yet grasp where the edge actually is.
Last edited by RadiKyle; 14 Dec, 2024 @ 8:32am
< >
Showing 1-15 of 28 comments
Per page: 1530 50