sullerandras / UtilizationMonitor

UtilizationMonitor: Factorio mod to see if factories are fully utilized
MIT License
0 stars 6 forks source link

Mod Crashing After Recent Update #17

Closed abordoli closed 6 years ago

abordoli commented 6 years ago

Mod Crashing After Recent Update Bordo - 12 hours ago  Edit

Gives a runtime error quite frequently and crashes to menu losing all unsaved work. I'll report back with the specific error script next time it happens.

Bordo - now  Edit

Here is the exact error and happens when an entity that is being monitored is deleted: " Notice Error while running event UtilizationMonitor:on_tick(ID o) UtilizationMonitor /control.lua:453: attempt to index local 'data' (a nil value) "

ST-DDT commented 6 years ago

I cannot reproduce that issue locally. But I have a guess on how to fix it.

Could you please try out this fix and report whether it works?

Replace control.lua#442

 if id then
    data = entity_data[id]
  else
    id, data = next(entity_data, nil)
  end

with:

if id then
    data = entity_data[id]
    if data == nil then
      id, data = next(entity_data, nil)
    end
  else
    id, data = next(entity_data, nil)
  end

If it does not work could you explain how to reproduce that error?

abordoli commented 6 years ago

I will try the fix and report back...

sullerandras commented 6 years ago

If the line number is correct, it is failing on this line: https://github.com/sullerandras/UtilizationMonitor/blob/05cad7c3ce0551a335ca66a6d1dead4b2f812003/control.lua#L453 My first idea would be to add a data != nil here, something like this:

if data != nil and data.entity.valid then

Would that work?