I've been making a serializer to allow me to convert lua userdata objects into JSONable tables, Im auto generating the code from the documentation, so far I have it working however I need to be able to serialize the defines values.
Although it makes sense how factorio works to have a sort of ENUM with the defines object is there any way of converting that data back into the definition variable name without having to have a table that converts to and from and manually maintaining this?
As an example of what I'd like:
Code: Select all
local someDefinitionValue = getDefinition(game.player.controller_type)
-- someValue == "defines.controllers.character"
Here's my code if anyones interested:
https://github.com/TomCaserta/FactorIO/ ... ialize.lua
As a side note, if thats not possible, does anyone know if the order of the defines mentioned on the documentation directly relates to the int value it gives?