Difference between engine script and simulation script


Abonniere unseren Kanal auf WhatsApp (klicke hier zum abonnieren).
  • I'm trying to modify a locomotives behavior but I'm still inexperienced in how the lua-scripts are used by Train Simulator.

    Many times a locomotive will have one main script such as "locomotive name script".lua and then in the Simulation folder there will also be a script. Are these divisions completely arbitrary or is there a general method of what will be controlled by the main script and what is controlled by the simulation-script?


    I presumed that the main script would call the engine script/simulation script but looking inside the main script I don't see any reference so maybe it is the simulation blueprint that calls it?

    Sorry if the question is too vague/general.


    EDIT: I had a look around in the main script and the engine script (latter located in Simulation folder) and that answered my first question. The engine blueprint calls the main script and the simulation-blueprint calls the engine script.


    Looking inside the main script I see very few references to TrainAirBrakeControl, actually the only reference/call is to set the train air brake to the initial application setting. I have some follow up questions instead:


    1. If I want to program the throttle to decrease according to the tractive effort curve rather than the default way of controlling this with the tractiveeffortvsspeed table. For example to also implement a delay and implement field weakening effects. Would this be programmed inside the script file inside the simulation folder or main script, or is it up to my choice?


    2. If I want to implement G-brake and P-brake slower application timings, is this something for the main script? I foresee that you could have a check for what the player sets the brake lever to and then call some function that slowly ups the virtual brake handle to this value.

  • I'll update this thread since I found the solutions to my questions. It seems like you can implement your functions in either the main script (like Armstrong Powerhouse does) or the simulation script.


    I'm trying to create more realistic brakes for my locomotive (more notches for example) but I'm unsure what the difference is between TrainBrakeControl and VirtualBrake. Is there a reason for using a VirtualBrake instead of only the TrainBrakeControl?

  • The simulation script is basically not used at all since years. It's kinda useless. You cant do the same from the simultion script as you can from the engine script AND the simulation script is only running when you are sitting in that vehicle. Both sccripts cant communicate with each other (only with numbers over translating controllers in the engine BP what is also mostly useless and restricted).

  • The simulation script is basically not used at all since years. It's kinda useless. You cant do the same from the simultion script as you can from the engine script AND the simulation script is only running when you are sitting in that vehicle. Both sccripts cant communicate with each other (only with numbers over translating controllers in the engine BP what is also mostly useless and restricted).

    Thanks Maik, I guess that's why the AP locomotives only have one line of code or so in the simulation script (an update function).


    If I want to control the rate of application (how fast the brake lever percentage increases in the sim) and other stuff like implementing clasp brake phyiscs (different percentage of brake for different speeds), can this be done by controlling the TrainBrakeControl directly or do I need to use VirtualBrake? I'm still kind of unsure what the use of VirtualBrake, VirtualThrottle etc is for, but I see it used in the complex trains such as AP, vR, 3DZUG etc.

  • A virtual control value is, as the name says, a virtual thing. It is used for the F4 HUD and can be used to unbind a control like the TrainBrakeControl from the hardcoded simulation part of TS. When you put in the VirtualBrake in your BP, it then replaces the hardcoded train brake lever in the HUD and you can use the TrainBrakeControl as an direct input from script to control the brakes without having the user being able to move it by the HUD. This is possible for most of the HUD presented levers and values. The Ammeter can be replaced by the VirtualAmmeter and so the HUD would show the value that you write onto that virtual control instead of the hardcoded simulation ammeter value.


    Thats a basic description of the behavior. What you then do with this is a completely different story and much more complicated. If you want to have your own brake cotrol behavior, then you need to script it completeley. You can use the VirtualBrake as the users input, do something with the given input value and write the result onto the actual TrainBrakeControl. Same for the Regulator what can be replaced by the VirtualThrottle. And so on....

  • A virtual control value is, as the name says, a virtual thing. It is used for the F4 HUD and can be used to unbind a control like the TrainBrakeControl from the hardcoded simulation part of TS. When you put in the VirtualBrake in your BP, it then replaces the hardcoded train brake lever in the HUD and you can use the TrainBrakeControl as an direct input from script to control the brakes without having the user being able to move it by the HUD. This is possible for most of the HUD presented levers and values. The Ammeter can be replaced by the VirtualAmmeter and so the HUD would show the value that you write onto that virtual control instead of the hardcoded simulation ammeter value.


    Thats a basic description of the behavior. What you then do with this is a completely different story and much more complicated. If you want to have your own brake cotrol behavior, then you need to script it completeley. You can use the VirtualBrake as the users input, do something with the given input value and write the result onto the actual TrainBrakeControl. Same for the Regulator what can be replaced by the VirtualThrottle. And so on....

    Thanks! I had the function of VirtualBrake and TrainBrakeControl mixed up, but your explanation makes perfect sense. I will basically let the user set the VirtualBrake to a specific value and then have TrainBrakeControl match it but more slowly.