Train Scaling


Automate the construction and deconstruction of your trains! Configure a train currently scheduled for a station as a template for the station - the mod's special train construction station will automatically build (or destroy) copies of the template train on demand, or in response to circuit conditions.

Content
2 years ago
0.16 - 1.1
5.01K
Trains

b Crash on 1.1

3 years ago
(updated 3 years ago)

The game throws the following error when trying to scale a train


The mod Train Scaling (1.1.0) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event train-scaling::on_gui_value_changed (ID 86)
__train-scaling__/control.lua:2667: bad argument #1 of 2 to '__newindex' (string expected, got number)
stack traceback:
    [C]: in function '__newindex'
    __train-scaling__/control.lua:2667: in function '?'
    __train-scaling__/control.lua:2849: in function <__train-scaling__/control.lua:2843>

I took a peek on the code and line 2667 points to this function


train_scaling_config_target_slider = function(event)
    local player = game.players[event.player_index]
    local entity = player.opened
    local station_config = global.enabled_stations[entity.surface.index][entity.force.name][entity.backer_name]
    event.element.slider_value = math.floor(event.element.slider_value)
    station_config.target = event.element.slider_value
    if station_config.target == station_config.current then
      station_config.target = nil
    end
    entity.last_user = game.players[event.player_index]
    event.element.parent.train_scaling_config_target_textbox.text = event.element.slider_value
  end,

Any ideas?

3 years ago
(updated 3 years ago)

Got it working:
2667: event.element.parent.train_scaling_config_target_textbox.text = tostring(event.element.slider_value)
Also:
2022: local parameters = behavior.parameters

3 years ago

The crash also happens if you enter a large values in the box. For me, it happened when I typed the last zero of 1000.

2 years ago

I've submitted a pull request to fix this at https://github.com/shanemadden/factorio-train-scaling/pull/12

2 years ago

That's great news. Thank you @roang

New response