Skip to content

Reference

davmarksman edited this page Apr 27, 2026 · 32 revisions

Better Signals - Reference

Here is an overview of all values that Better-Signals provides in params in updateFn = function(params)

signal_state [0/1]

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
end

signal_speed [0-∞]

signal_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 ...
end

previous_speed [0-∞]

previous_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
end

entity [0000-9999]

entity returns the id of the entity the signal is linked to.

paramsOverride

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
end

NOTE: Be aware that all numeric values will get converted into numbers. So if you want to test for params.paramsOverride.trackNr == 2 make 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=true on a waypoint can be detected like this: params.paramsOverride.minor == 1 meaning minor is true.

following_signal [table]

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
end

The following_signal of following_signal

To access a signal 2 away from the current signal use

if params.following_signal.following_signal then
  ...
end

is_station [true/false]

isStation 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
end

construction_params [array of tables] (Version 1.2)

construction_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