Transport Fever

Transport Fever

Not enough ratings
Spreadsheet Fever
   
Award
Favorite
Favorited
Unfavorite
Tags: Ui Mod
File Size
Posted
1.166 MB
Jul 9, 2019 @ 10:06pm
1 Change Note ( view )

Subscribe to download
Spreadsheet Fever

Description
*Spreadsheet Fever*

Spreadsheet Fever is Transport Fever UI mod that bypasses the game's internal UI. We do this mostly for performance, but also to declutter the game's window. The mod updates a log of stopped trains on every frame, and generates an html overview of rail and factory activity once per second. Note: this mod uses TF's mission infrastructure, and therefore can only be used in free-play mode, not campaign mode.

Before this UI, I kept a vehicle overview window opened for every train, so that I could see when train became blocked, unable to find a path the the destination in the first place, or otherwise bothered, as well as to eyeball each line's source factory outputs. This slowed the game to a crawl. With vehicle and ka-ching icons disabled in the central HUD menu, I was able to get about 4fps running below 1x speed with 55 train windows opened. (I had to close half the windows to avoid severe lag when laying out track while paused.) After the mod, with train windows eliminated, I can get around 40fps at a smooth 4x speed.

I haven't tried to measure the impact of this mod's lua code on the TF engine, but it feels minimal. As for the increased CPU load from the web browser reloading a small page every second, it shouldn't be an issue. I've never seen TF fully utilize 2 cores on Linux (it consistently stays around 1.5), while my 9 year old CPU has 4 cores and 8 threads.

I like to think of the web page as primitive but functional. It doesn't include everything I'd like, but then everything I'd like isn't available in lua.

*Release Status*

Alpha: So far, this mod is confirmed to work on Ubuntu 18.04 with firefox. I don't expect problems from other browsers, other UNIX variants, or MacOS, but I do expect problems with Windows. scripts\\init.bat probably contains errors right now, so Windows users might want to try this script manually before enabling the mod in TF.

*Usage*

When the game starts, follow the directions in the Observer dialog box:

This dialog box is the only native UI element in Spreadsheet Fever. To see the rest, point your browser at file:///tmp/tf-dash/dash.html, and run tail -f /tmp/tf-dash/stop-log.txt in a terminal. (In windows, these paths are relative to the drive where Steam is installed.

There are a few config options, which you can control by adding a .tfdashrc or tfdask.rc file to your home directory based on the following template (which you can find in mods/settings.lua relative to your TF install path):

-- Configuration for Spreadsheet Fever.
function data()
return {
speedUnit = "MPH", -- MPH, KPH, or mps (meters/sec)
fontSize = "8pt", -- compact
menuFontSize = "7pt", -- a little more compact
}
end

If you have trouble loading your config in Windows, set %HOME% or both %HOMEDRIVE% and %HOMEPATH% appropriately.

*Developers*

Relative to the TF mods/urbanspreadsheets_webdash_1 directory, we have a few interesting files:

mod.lua is responsible for running scripts/init or scripts/init.bat as appropriate to initialize the /tmp/tf-dash dir.

www/tf-dash.js and www/tf-dash.css contain webpage-enabling garbage.

campaign/_auto_/_auto_/script.lua contains the core logic: makeObserver() establishes our end-of-frame callback and calls checkHealth() (to update stop-log.txt) and genFile() (to overwrite dash.html) when appropriate.

Git access at github.com/trainspotter6/spreadsheet-fever

I've scribbled my thoughts on where to go from here in wishlist.md.

*Limitations*

The Spreadsheet Fever dashboard is very much limited by TF's lua api:

No view into train "waiting for path"/"unable to find path" status, we just complain when a train's speed drops to zero when not at a station.

No breakdown of cargo or people waiting at a station by line or even by terminal.

No way to see the advertised production rate of a factory. We see some stats, but nothing corresponding to the rate shown in in-game overview windows.

Time is weird. With the default settings, each day of Calendar time equals 2 seconds of vehicle time. We get them both through a single function game.interface.gameTime() merge both into a single number, then disentangle them when generating stop-log messages.

No way to examine user settings stored in the steam userdata dir (eg speedUnit).

*Endnotes*

All source files are copyright by their respective authors, while images in the www/ dir are copyright Urban Games. If you download this mod without buying Transport Fever, you are pirating icons! Icons, I tell you!

Spreadsheet Fever code is free software, see LICENSE for conditions.
< >
37 Comments
tsilaicosneknurd Nov 20, 2019 @ 2:47pm 
invalid entitiy id: -1
here too
tsilaicosneknurd Nov 10, 2019 @ 9:29am 
error: error: mods/1798764257_1/res/campaign/_auto_/_auto_/script.lua:471: attempt to index local 'f' (a nil value)

you should make sure "local f = io.open("/tmp/tf-dash/dash.html", "w+")" succeeds, in my case the directory /tmp/ tf-dash/ didn't exist.
VacuumTube Oct 26, 2019 @ 1:10am 
yeah I guess that was because of the assertion. try deleting the line with assert(...)
Gibbanator Oct 20, 2019 @ 5:20pm 
can you update this for it works? soon as you turn it on the sytex errors and game crashes

Pc steam Windows 10 user
VacuumTube Sep 1, 2019 @ 3:27am 
About the performance... I just tried it on my old savegame with a lot of trains. I had 7 fps with the mod and 25 fps without. So with a little vehicles the impact might be little but not with a lot because I think the data about all the trains, lines and industries is calculated every frame.
Co-Chief Scrub  [author] Aug 23, 2019 @ 8:01pm 
@VacuumTube Thanks for all the feedback. Despite my laziness, I do appreciate it. @canophone has a fix for the time format just after you in the comments. I'll apply fixes and take a look at the rest real soon now. As for the <drive>:\tmp question, the docs already talk about the steam drive, but a concrete example as you suggested would probably stand out more.

It looks like my eu4 campaign can end in a world conquest (my first), but these last few decades are taking forever. My people have no war exhaustion, but I have plenty on their behalf.
VacuumTube Aug 23, 2019 @ 3:03pm 
Anyway I got it running finally and I think it's a very nice idea.
But I got an error after a while error: error: ...adsheets_webdash_1/res/campaign/_auto_/_auto_/script.lua:240: bad argument #1 to 'date' (invalid conversion specifier '%F %T')
and if I buy a train I get: invalid entitiy id: -1
VacuumTube Aug 23, 2019 @ 2:52pm 
Ok I finally found the log file and html on windows (the root dir of steam, for example D:\tmp\tf-dash). Another problem was that you assume, the script is in mods/urbanspreadsheets_webdash_1/... but I had a different folder name (how is this even gonna work in the workshop folder?)
VacuumTube Aug 23, 2019 @ 2:24pm 
Why are you asserting if there is content in lines? There is always after running the batch script.
VacuumTube Aug 23, 2019 @ 1:53pm 
To the bat file on windows:
-there is no deltree
-the copy commands and the mkdir maybe dont work because of the directory relations