Bug: on_runtime_mod_setting_changed handler crashes when another mod changes a setting from script
kry-picker-extended/scripts/itemcount.lua:48 errors with bad argument #3 of 3 to '__index' (string expected, got nil) whenever any mod writes a runtime-global setting from script. Script-initiated settings changes deliver the event with event.player_index = nil (only changes a player makes through the Mod Settings GUI carry an index — see the API docs for on_runtime_mod_setting_changed), and line 48 appears to index with it unguarded.
Reproduced deterministically: a one-line mod doing settings.global["any-setting"] = { value = ... } triggers it; in multiplayer it surfaces as a repeated chat error. Original user report (triggered via Rail Logistics Daemon’s pause control, but any script-side settings write does it): https://mods.factorio.com/mod/RailLogisticsDaemon/discussion/6a8a23e82d21a8edabe3087b
Suggested fix: early-return when event.player_index is nil (or when event.setting_type ~= "runtime-per-user", if the handler only cares about per-player settings — that also skips other mods’ global settings entirely).