[2.0.43] LogisticSection::set_slot is dangerous (easily crashes mods)

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
kryojenik
Inserter
Inserter
Posts: 45
Joined: Fri Jun 26, 2020 8:18 pm
Contact:

[2.0.43] LogisticSection::set_slot is dangerous (easily crashes mods)

Post by kryojenik »

In 2.x a logistic section can only contain a given filter once. For historical context, 1.x allowed duplicate signals to be created in a control behavior and it summed the values. This now happens between duplicate signals across unique logistic sections on the same combinator.

The built in chooser prevents you selecting the same signal twice. Running set_slot in the console returns an error. "Filter conflicts with filter in slot 1.".
pic
However, when using set_slot in mod lua and unknowingly colliding with an existing signal, the mod crashes with the same error.

Code: Select all

The mod Editor Extensions (2.5.0) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event EditorExtensions::on_entity_settings_pasted (ID 37)
Filter conflicts with filter in slot 4.
stack traceback:
	[C]: in function 'set_slot'
	__EditorExtensions__/scripts/infinity-loader.lua:92: in function 'copy_from_loader_to_combinator'
	__EditorExtensions__/scripts/infinity-loader.lua:189: in function 'handler'
	__core__/lualib/event_handler.lua:47: in function <__core__/lualib/event_handler.lua:45>
It appears at present, the way to avoid this crash is to precede every set_slot call with a loop that compares each slots name and quality to the filter you are tying to set and determine if there is a collision, or to wrap every set_slot call in pcall and parse the error message for the colliding filter to do something with it.

As a possible suggestion, if set_slot would silently fail and return the colliding slot index on collision, that would help a lot.
Post Reply

Return to “Modding interface requests”