Reproduction steps:
1) Download and enable the attached mods (simple mods to demonstrate this issue - they each create a button in the mod_gui, and reference that button in the button clicked and on_player_cursor_stack_changed events).
2) Start a new game, and make a save.
3) Disable mod "AAAA", then reload the save.
4) Notice that both buttons have been removed from the top-left mod gui flow.
5) Pick up something with your cursor to trigger the event, and observe a crash due to the button now being invalid:
Code: Select all
Error while running event BBBB::on_player_cursor_stack_changed (ID 36)
LuaGuiElement API call when LuaGuiElement was invalid.
stack traceback:
[C]: in function '__index'
__BBBB__/control.lua:33: in function <__BBBB__/control.lua:
There appears to be an order dependency here - if in step 3 you instead disable mod "BBBB" and reload the save, the issue does not occur. The button created by AAAA is still in the button flow, clicking it works, and the cursor change event continues to work.
Ideally, removing an unrelated mod should not invalidate buttons created by a different mod, and not be dependent on the order those buttons were created.