Expand potential of TCS scripting
#41
Posted 30 April 2020 - 02:09 AM
Carlo, can I see the syntax somewhere? How will they be used?
#42
Posted 30 April 2020 - 03:48 AM
Icik,
sorry, but I don't understand your question well. The syntax of what? For the script a stroke of the above key combinations will be the same as the mouse click on the ORTS_TCS1 or ORTS_TCS2 cab control.
sorry, but I don't understand your question well. The syntax of what? For the script a stroke of the above key combinations will be the same as the mouse click on the ORTS_TCS1 or ORTS_TCS2 cab control.
#43
Posted 30 April 2020 - 04:14 AM
How do I handle to turn TCS on / off with a keyboard shortcut? Is there a function for this?
#44
Posted 30 April 2020 - 05:20 AM
This must be coded within the script itself. The TCS script starts always, but loops doing practically nothing until the starting keystrokes are pressed.
#45
Posted 30 April 2020 - 07:41 AM
Csantucci, on 28 April 2020 - 12:52 PM, said:
As requested, two keyboard commands have been added in the TCS extensions; they are triggered by Ctrl+, and Ctrl+. . They are linked to the generic TCS controls ORTS_TCS1 and ORTS_TCS2. The commands are generic, and may be have any use within the TCS script. They might be used to start and stop the on-board Train Control System, but also for other functions.
This is now implemented in OR NewYear MG rev.60 and in the latest official Unstable release, where also all other TCS extensions are now available.
#46
Posted 30 April 2020 - 11:27 PM
Carlo, I don't know how or what to test in the script to get true / false when I press Ctrl + or Ctrl + ..
Please, give me an advice.
Please, give me an advice.
#47
Posted 01 May 2020 - 10:14 AM
Hi Icik,
you can download here http://www.interazio...ev8.0_provv.zip a new temporary release of the script for the Italian TCS, where I have implemented the check for key combinations Ctrl,(comma) to switch on the on board TCS and Ctrl.(period) to switch it off.
I also suggest you to update tomorrow morning the Testing version of OR. There should be an update in the OR manual, where YoRyan has written the basics of OR scripting.
The SCMT source is quite complicated. Here some hint about the points where the checks are performed. When one of the two key combinations are pressed and when they are released, method
at line 1883 of the script is called, and in particular lines from 1908 and further on are activated.
Key combination Ctrl,(comma) or Ctrl.(period) start HandleEvent; evt can have the two values TCSEvent.GenericTCSButtonPressed (when you start pressing the keys) and GenericTCSButtonReleased when you release them; message can be in our case "0" (string) for Ctrl,(comma) and "1" for Ctrl.(period). Within HandleEvent they are converted to integers and then to CommandEvent enums respectively as TCSCommandEvent.Accendi (switch on) and TCSCommandEvent.Spegni (switch off) and become indices for TCSButtonPressed[(int)commandEvent] and TCSButtonReleased[(int)commandEvent].
The relevant elements of TCSButtonPressed are then read within the update loop in UpdateSSBState() (line 1024). That method should be clear.
you can download here http://www.interazio...ev8.0_provv.zip a new temporary release of the script for the Italian TCS, where I have implemented the check for key combinations Ctrl,(comma) to switch on the on board TCS and Ctrl.(period) to switch it off.
I also suggest you to update tomorrow morning the Testing version of OR. There should be an update in the OR manual, where YoRyan has written the basics of OR scripting.
The SCMT source is quite complicated. Here some hint about the points where the checks are performed. When one of the two key combinations are pressed and when they are released, method
public override void HandleEvent(TCSEvent evt, string message)
at line 1883 of the script is called, and in particular lines from 1908 and further on are activated.
Key combination Ctrl,(comma) or Ctrl.(period) start HandleEvent; evt can have the two values TCSEvent.GenericTCSButtonPressed (when you start pressing the keys) and GenericTCSButtonReleased when you release them; message can be in our case "0" (string) for Ctrl,(comma) and "1" for Ctrl.(period). Within HandleEvent they are converted to integers and then to CommandEvent enums respectively as TCSCommandEvent.Accendi (switch on) and TCSCommandEvent.Spegni (switch off) and become indices for TCSButtonPressed[(int)commandEvent] and TCSButtonReleased[(int)commandEvent].
The relevant elements of TCSButtonPressed are then read within the update loop in UpdateSSBState() (line 1024). That method should be clear.
#48
Posted 01 May 2020 - 12:38 PM
I'm working on some American TCS scripts, and I'm missing the ability to read the current positions of the throttle and brake handles. For example, when you get a penalty application on an American locomotive, you have to move the brake handle to Supression for 10 seconds before the TCS system will release the brakes.
Any chance of incorporating such a function into your changes?
Any chance of incorporating such a function into your changes?
#50
Posted 01 May 2020 - 11:52 PM
YoRyan, on 01 May 2020 - 12:38 PM, said:
I'm working on some American TCS scripts, and I'm missing the ability to read the current positions of the throttle and brake handles. For example, when you get a penalty application on an American locomotive, you have to move the brake handle to Supression for 10 seconds before the TCS system will release the brakes.
Any chance of incorporating such a function into your changes?
Any chance of incorporating such a function into your changes?
Hi Ryan,
I'm happy you're working on that.
With this hook that I added some days ago
Script.Locomotive = () => Locomotive;
you have access to the whole Simulator environment (locomotives, trains, signals and so on), e.g. in the script you can refer to
Locomotive().LocalThrottlePercent
provided you have inserted the required using lines at beginning of the script.