The problem appears to be that this is the table that exists in the 'data' variable sent to on_configuration_changed:
{
mod_changes= {
ElectricTrainPatched= {
new_version= "1.1.3",
},
ElectricTrain= {
old_version= "1.1.2",
},
},
mod_startup_settings_changed= "false",
migration_applied= "false",
}
So, when GetNewVersion is called, with the old "ElectricTrain" name, the value is nil.
This code is unchanged from version 1.1.2 of ElectricTrain, but this points out a bug for the corner case of upgrading from ElectricTrain to ElectricTrainPatched.
I implemented a fix by simply passing the string "ElectricTrainPatched" to the call to GetNewVersion, instead of passing the modName local variable to it, which isn't used anywhere else, anyway.