-
Notifications
You must be signed in to change notification settings - Fork 2
Reference
Here is an overview of all values that Better-Signals provides in params in updateFn = function(params)
signal_state returns the state of the linked signal and indicates if a train will stop in front of the signal.
- 0: Signal is red. Trains will stop in front of the signal
- 1: Signal is green. Trains will pass the signal
if params.signal_state and params.signal_state == 1 then
-- display green
else
-- display red
endsignal_speed returns the lowest speed between this and the next following signal. Speed is in km/h
if params.signal_speed and params.signal_speed <= 20 then
-- display 20km/h
elseif params.signal_speed and params.signal_speed <= 30 then
-- display 30km/h
elseif ...
endprevious_speed returns the lowest speed between the prior and this signal. Can be used to figure out if there was a speed difference. Speed is in km/h
if params.previous_speed > params.signal_speed then
-- display slow_down
endentity returns the id of the entity the signal is linked to.
params_override returns all values defined by waypoints on the path to the next signal. - Users can place waypoints between signals and change the name of the waypoints to pass additional values to the signals. This also works if the waypoints are placed on different branch lines. Therefore, this system can for example be used for switch indicators. All values that follow the pattern of key=value will be passed on to this parameter. Multiple values can be separated using a ,. It is important to explicitly check if the key isn't nil - in order to prevent crashes.
It's also important to note that speed=[number] will automatically change the speed value provided in signal_speed
if params.paramsOverride and params.paramsOverride.track and params.paramsOverride.track == 'a' then
-- display track A is used
endNOTE: Be aware that all numeric values will get converted into numbers. So if you want to test for
params.paramsOverride.trackNr == 2make sure to test for the value as a number instad of a string.
NOTE: Boolean values are also treated as number values. For example:
minor=trueon a waypoint can be detected like this:params.paramsOverride.minor == 1meaningminoris true.
following_signal returns a table with all the above parameters - but from the perspective of the next signal on the path. Therefore, it can be used to indicate more complex "signal-faces" that take the following signals into account. A following signal can, but doesn't have to, include another following signal. So it's advised to explicitly check for params.following_signal before accessing one of its values.
if params.following_signal and params.following_signal.signal_state and params.following_signal.signal_state == 0 then
-- display warning - next signal shows stop
endTo access the signal 2 away use
params.following_signal.following_signalisStation returns if the signal is a stop. (Only available in followingSignal)
if params.following_signal and params.following_signal.isStation then
-- this signal is the last signal before a station
endparams is a value unique to following_signals. It contains all non signal related parameters in a list. So for example x_offest, y_offset, given the construction has these. Therefore the values passed here are unique to the signaling_pack used by the players. So it's advised to use this value accordingly.
if params.following_signal and params.following_signal.params and params.following_signal.params.special == 1 then
-- display special preSignal
end