Any way to get the variable name of a definition value?
Posted: Fri Dec 23, 2016 11:22 am
So I am currently working on a project to allow for input and output from factorio to nodejs/web services to run code.
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:
I suspect this isnt possible since it is just a integer value but I thought I'd ask just in case any one knows of built in way.
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?
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?