-
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.
paramsOverride 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 instead 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 a signal 2 away from the current signal use
if params.following_signal.following_signal then
...
endisStation returns if the signal is a stop/station. (Only available in following_signal)
if params.following_signal and params.following_signal.is_station then
-- this signal is a station
endconstruction_params is a value unique to following_signals. It contains all non signal related parameters in a list. So for example x_offset, 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.
A signal may have: 0 (none placed on the signal yet by the player), 1 (normal case) or several signal constructions (some submods support this) attached to it.
local has_signal_prop = false
local fs = params.following_signal
if fs and fs.construction_params then
for _, cp in ipairs(fs.construction_params) do
if cp and cp.signal_pack_custom_cons_param and cp.signal_pack_custom_cons_param == 1 then
has_signal_prop = true
break
end
end
end