factoriolib / flib

A set of high-quality, commonly-used utilities for creating Factorio mods.
https://mods.factorio.com/mod/flib
MIT License
61 stars 15 forks source link

__flib__/dictionary.lua:154: attempt to index field '?' (a nil value) #46

Closed billbo99 closed 1 year ago

billbo99 commented 1 year ago

I am using your mod "flib_0.10.1" to translate locales for my mod, as soon as I logged in to our multiplayer server the server crashed with this error

 100.203 Error MainLoop.cpp:1284: Exception at tick 98160418: The mod TSM Helper Addon (1.5.1) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event TSM_Helper::on_string_translated (ID 153)
__flib__/dictionary.lua:154: attempt to index field '?' (a nil value)
stack traceback:
        __flib__/dictionary.lua:154: in function 'request_translation'
        __flib__/dictionary.lua:319: in function 'process_translation'
        __TSM_Helper__/control.lua:68: in function <__TSM_Helper__/control.lua:67>

I am not sure which part is returning a NIL local string = raw[player_data.dictionary].strings[player_data.i]

raiguard commented 1 year ago

Have your mod's dictionaries already been generated by (generated, not translated) the time the player joins? If there are no dictionaries, then player_data.dictionary will be nil.

raiguard commented 1 year ago

I was finally able to reproduce this, thanks to Honktown on the factorio discord. It turned out to be a very small typo in the translation canceling logic. It shouldn't crash any more!