Auto deploy combat robots


Automatically deploys combat robot capsules when in combat. No special equipment required.

Utilities
1 year, 6 months ago
1.1
1.19K

b [Fixed] Mod crashes when using shortcut to modify runtime mod settings for another mod

1 year, 8 months ago

Error message:

```The mod LTN - Logistic Train Network (1.16.10) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event LogisticTrainNetwork::ltn-toggle-dispatcher (ID 223)
The mod Auto Deploy Combat Robots (0.0.4) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event auto-deploy-combat-robots::on_runtime_mod_setting_changed (ID 61)
auto-deploy-combat-robots/autodeploy.lua:84: bad argument #3 of 3 to 'index' (string expected, got nil)
stack traceback:
[C]: in function '__index'
__auto-deploy-combat-robots
/autodeploy.lua:84: in function <auto-deploy-combat-robots/autodeploy.lua:83>
stack traceback:
[C]: in function 'newindex'
__LogisticTrainNetwork
/script/hotkey-events.lua:13: in function <LogisticTrainNetwork/script/hotkey-events.lua:8>```

According to https://lua-api.factorio.com/latest/events.html#on_runtime_mod_setting_changed, you do not always get player_index in all events, hence your mod crashes mod settings changed due to shortcuts. I suggest you compare the setting and setting_type strings in the handler (to decide whether to create the settings table) to reduce unnecessary API calls to player.settings.

[deleted message]
1 year, 8 months ago

Thanks,

I thought that on_runtime_mod_setting_changed without any nil check might crash game under some conditions, but since I did't find such scenario during testing I didn't bother adding any checks. "Someone will report a crash if/when that happens" :)

Anyway, thanks for reporting. It should now be fixed.

New response