C# Signal Scripts
#16
Posted 26 September 2021 - 12:42 PM
#17
Posted 07 December 2021 - 04:08 AM
Is it some way for Signal Script to define a Multiplayer Mode?
Regards
Oleg
#18
Posted 07 December 2021 - 07:31 AM
else if (BLOCK_CLEAR !=# block_state())
{
if (Approach_Control_Position (Approach_Control_Req_Position))
{
Activate_Timing_Trigger();
}
}
else if (block_state() !=# BLOCK_CLEAR &&
( Check_Timing_Trigger( 120 ))
)
state = SIGASP_STOP_AND_PROCEED;Hello.
Do I think the timer in the code above doesn't work because of this?
Sincerely, Laci1959
#19
Posted 07 December 2021 - 09:46 PM
VicenteIR, on 07 December 2021 - 04:08 AM, said:
Is it some way for Signal Script to define a Multiplayer Mode?
Regards
Oleg
Err... what do you mean ?
Laci1959, on 07 December 2021 - 07:31 AM, said:
else if (BLOCK_CLEAR !=# block_state())
{
if (Approach_Control_Position (Approach_Control_Req_Position))
{
Activate_Timing_Trigger();
}
}
else if (block_state() !=# BLOCK_CLEAR &&
( Check_Timing_Trigger( 120 ))
)
state = SIGASP_STOP_AND_PROCEED;Hello.
Do I think the timer in the code above doesn't work because of this?
Sincerely, Laci1959
I don't know. I have never used those functions in MSTS signal scripts. But anyway, this is a topic about C# signal scripts, so I don't think this is here we should talk about it. Perhaps opening a topic in "Maybe it's a bug" is appropriate.
#20
Posted 08 December 2021 - 09:23 AM
Serana, on 07 December 2021 - 09:46 PM, said:
I don't know. I have never used those functions in MSTS signal scripts. But anyway, this is a topic about C# signal scripts, so I don't think this is here we should talk about it. Perhaps opening a topic in "Maybe it's a bug" is appropriate.
Thanks, I'm sorry, I misunderstood. I thought there might be a connection.
#21
Posted 16 December 2021 - 04:53 AM
Serana, on 07 December 2021 - 09:46 PM, said:
I would like to define a different logic for some signals when the game is in Multiplayer mode. Is it possible with the c# script by calling IsMultiplayer() function for example? What am I need to add to the code if so?
Regards
Oleg
#22
Posted 16 December 2021 - 01:38 PM
Currently, this information is not available for C# signal script.
#23
Posted 16 December 2021 - 11:15 PM
Regards
Oleg
#24
Posted 17 December 2021 - 10:48 PM
I thinking maybe with c# scripts it will be possible. Especially since those signals anyway will be written in c# because of possibility of communication between a Signal and the following one.
Regards
Oleg
#25
Posted 18 December 2021 - 12:10 AM
I believe the feature you mention, i.e. that a signal is held at danger until the dispatcher clears it, and once the train passes it is closed again, is standard for non automatic signals, and therefore could be implemented in the internal OR signalling logic, with some way of telling the simulator to enable or not the feature.
Regarding enabled signals, I don't understand why Enabled always return true in multiplayer mode, this causes inconsistent behaviour. Maybe another addition that can be done is that signals only clear in the current train direction, and not backwards.
My recommendation is that signal messages should be used with care, and only where it is strictly necessary (e.g. when the state of a signal depends on the aspect of the previous signal). It should not be used as a replacement of the internal OR signalling logic. The order to clear or to close a signal should come from the interlocking, and then the signal will show the corresponding aspect obeying it.
#26
Posted 13 September 2022 - 06:55 PM
I have a case where the route is so huge (so it has a huge number of signals) and, on some computers, even with optimizations to create less strings, the garbage collector can sometimes not be quick enough and we get slow memory leaks.
Two solutions I am thinking about:
- Getting direct access to the signal script of another signal through a function that return the reference to the signal script. That means the signal (or maybe the TCS also) can get access to public members of the signal script.
- Or setting values to be exchanged in a custom object that can be then be accessed from another signal, or from a TCS script.
Not having to serialize and unserialize signalling information would help a lot.
What do you think about these solutions?
#27
Posted 14 September 2022 - 10:51 PM
Quote
I have a case where the route is so huge (so it has a huge number of signals) and, on some computers, even with optimizations to create less strings, the garbage collector can sometimes not be quick enough and we get slow memory leaks.
Yes, string manipulation has to be done with care for this scripts. There are a lot of signals being cyclically updated. For my scripts, I tried to minimize heap allocations taking two different approaches:
- For normal signals: I use pre-allocated strings to extend the 8 MSTS aspects to the 16 aspects needed by Spanish signalling. This approach doesn't use heap allocation.
- For ETCS balises: the text aspect corresponds to the binary-encoded telegram, which is dynamically constructed. In this case, there's a lot of string manipulations, which I try to reduce by using string builders where possible. Also, telegrams are updated only when there is a relevant change in signalling (this feature is also used to fill the M_MCOUNT balise message counter). Because of this, the performance impact should be negligible.
I don't see any problem in principle for giving access to signal scripts in other signals, as that would be faster than communicating with strings. Depending on the info that you want to transmit, you can also use the shared Dictionary<int,int> containing each signal's local variables.
For communication with TCSs there's a problem: in Multiplayer mode the signalling information is only fully available at the server, so anything that is made available to the TCS has to be serialized and sent through the internet.
I see that you encode data to be used for different TCSs into the same string, using lists to encode and decode. This is very expensive if it has to be executed several times in the same update cycle. Would it serve your purposes if the localStorage Dictionary is made available to the TCS scripts?
#28
Posted 21 March 2025 - 01:13 PM
Continuous changes on the railways in Poland forced us to create new signalling scripts for the game, but in reality we are doing everything from scratch.
From what we know in OpenRails, a semaphore can have 8 different speeds defined in SignalType, however, after deducting SignalAspects used for other purposes (STOP, subsidiary signal, shunting signal and Vmax) only 4 remain, which additionally must be properly recognized by the previous signal to warn the driver about the approaching restriction.
A question for people creating signaling scripts: do they have any ways to make it possible to freely set permitted speeds on the semaphore in OR, or are we only limited to these 8 states and do we have to duplicate SignalTypes to create variants for different values?
In Poland 3 main speed limit values given by the semaphore are in use: 40, 60 and 100 km/h; however, for some time now indicators have been installed that in practice can determine other values of the permitted speed behind the semaphore (e.g. 50, 80, 90, 130 km/h).
https://en.wikipedia...ight%20signals.
Thank you
#29
Posted 22 March 2025 - 02:35 AM
You can then set the local variables of the main signal to indicate the required speed - you can use as many values or as many different local variables as you like.
The speed signal(s) placed ahead of the main signal can then use the local variable(s) of the main signal to set the required speed.
This way you can have a particular signal state but with different speed settings.
For the functions to use the local variables see the manual - e.g. store_lvar, next_sig_lvar and id_sig_lvar.
Regards,
Rob Roeterdink
#30
Posted 22 March 2025 - 03:22 PM
So my questions will be:
1. How signal can check the required local variables? What function is responsible for that? Could you provide any existing example to help me understand?
2.If I understand correctly, SPEED type signals are supposed to set the permitted speed.In that will setting different indicators (I.e signs) not cause this limit to be incorrectly changed?

Log In
Register Now!
Help






