Posts by doug

Willkommen in der Transport Fever Community

Welcome to the fan community of Transport Fever and Train Fever, the economic simulators of Urban Games. The community is free for you to share and inform yourself about the game. We cultivate a friendly and objective interaction with each other and our team will be happy to answer any questions you may have.


Registration and use is of course free for you.


We wish you a lot of fun and hope for active participation.

The Team of the Transport-Fever Community

    OK, so you actually want:

    for i = 1, #data.metadata.transportVehicle.compartments do

    for j = 1, #data.metadata.transportVehicle.compartments [i] do

    data.metadata.transportVehicle.compartments [i] [j][1].capacity = 396



    I think...

    As I later thought about this, I realized you probably only need the first function. You could adapt it to be your callback for the addModifier.

    My example was a little more complex because I was checking for the ability of the vehicle to carry goods before I added mail.

    I don't think you will have issues with visible cargo. Capacity is separate from the definition of the visibility conditions in the model file. If you are in fact adding a new cargo type, you can copy the visibility definition from one of the existing entries when you create the new entry.

    A Steam user with the handle mav12222 created a mod to implement mail as a cargo. He added the ability to carry mail to only a limited number of vehicles. This is how I added mail as a cargo type to anything that carrys goods. You could probably use it as a model to change capacities:

    The 'Start Paused' mod I posted a couple of days ago uses a game script file. There are actually two files needed - one in 'res/config/game_script' that loads the other, which is located in 'res/scripts'

    It is this second file that contains the actual functions that will be called on each update or event.

    Ok, nice to know.

    However, the problem with my mod is, that I'm calling that function in addModifier in runFn and in this mod thread game==false, so game.interface is not available.

    Maybe I need to combine that with the new GameScript, but dont know how yet.

    The 'game' variable is available in the runFn function of a mod. However, the modifier function, even if it is defined inline within runFn, does in fact run in a different thread - a thread where 'game.interface' is not available.

    The bogies were a separate mod. I don't recall who published it, but it shouldn't be too hard to track down. There were a number of TpF1 rail cars that used it.


    For mods located outside the Transport Fever 2 directory tree, the 'fileName' variable will be the fully qualified file name (i.e. everything including the drive letter.)

    You would probably be better served with:

    if string.find(fileName, "vehicle/train/loco1.mdl") ~= nil then

    Inline function definitions are allowed. I think you want:

    Edit: This is kind of OT for this thread. If this example doesn't work for you, start a new thread and we can look for solutions.

    I'm talking about if a player is using the Expanded Industry, the mod Freestyle industry would show expanded industry cargos. If the play is using just the mail mod FSI would also show just 16 vannila cargoes + mail as an option.

    You can include an addModifier function in the runFn of your mod:

    runFn = function(settings)

    addModifier( "loadCargoType", cargoHandler )

    end --runFn

    Also define the handler:

    local function cargoHandler(fileName, data)

    if string.find(fileName, 'res/config') ~= 1 then

    -- an addon has defined a cargo type, so do what needs doing


    return data


    Knowing what you're looking for, another possible solution comes to mind:

    On each update, call getVehicles()

    For each vehicle, add its current speed to an accumulator variable for its line.

    Increment a counter for the line.

    Dividing the accumulator by the counter should give you a pretty good indication of the overall speed of the line.

    Using a ton of mods, mostly vehicles. I don't think there are any that will directly affect the number of buildings - I'll have to check.

    As to the skyscrapers, I'm wondering if it would be possible to build a mod that will simply replace the stock period C buildings with copies of the period B ones. Just musing out loud here - don't know what affect that would have on town development...

    I take it you're looking for something more accurate than the straight line distance between stops.

    You could track the distance travelled by a unit as it covers the route.

    This would involve keeping track of its position and speed at each update, so that you could measure the distance travelled.

    I would start measuring when the vehicle first reached a station (any station.) Measure the distance travelled on each update until it next reaches that station.

    You would need to keep a table of information for each line that included the vehicle being tracked, last position, last time, accumulated distance, station at start, measurement status (not started, in progress, complete,) etc.

    A non-trivial exercise, for sure.

    I've never had issues with frame rates in this game. If I get close to one of Enzo's underground stations, or I leave a whole bunch of windows open on the screen, they'll drop down to 25 or so, but otherwise they're usually in the 50 - 60 range.

    Each person needs three buildings - home, shopping, work, so it does make sense that there are more town buildings than people.

    OK, thanks. Up until now, I had only tested it on one map. I have another in progress, which, conveniently enough, just crash, so I have to restart anyway...