I was working on a Python library to help me build Factorio tools (a Factorio tool meta-tool if you will
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
I'm in the midst of writing a library that can load a static schema file, defined in JSON (the WIP is provided below). This schema file most importantly defines the inheritance order of the various types (e.g., an accumulator is an EntityWithHealth is an Entity). A Python module loads this schema and turns it into Python classes that you can instantiate [2] with the Lua objects. You can even get useful results if you run help on the module, e.g.:
example help output
The WIP I have for the schema is below. I copied it mostly from the existing wiki pages, but there's a lot missing. The latter two sections are entirely guesswork on my part as to the hierarchy, and so I have 0 confidence in them. I'm also missing several tables entirely (beam, blueprint, combat-robot-count, curved-rail, custom-input, deconstructible-tile-proxy, deconstruction-item, electric-energy-interface, entity-ghost, fire, fluid, item-request-proxy, leaf-particle, module-category, particle-source, rail-planner, rocket-silo-rocket, rocket-silo-rocket-shadow, simple-entity, smoke-with-trigger, straight-rail, stream, tile-ghost, utility-sprites, virtual-signal). The optional/mandatory details according to the wiki seem wrong, given that several items seem to lack them at times.I do hope to validate the types and default values, but that is somewhat less important to me than getting the entire hierarchy accurate first.Prototype schema definition
If any developers are reading this thread, can you validate my facts? I could give you the Python help tree if it helps (or even the module code, though you probably have to be on Linux to get it to work). It would be even more wonderful if this kind of information could be produced automatically (like the LUA documentation), but I'm guessing that the code isn't so nicely structured as to give this information with automated documentation tools.Thoughts/questions/comments/concerns?
[1] Turns out that Lua's custom module loader requires that the data in question be a function, not merely something callable. So I had to write a Lua function that returns a lua function that calls a function passed into it and call the function from Python to get the right data type. Aren't proxies fun?
[2] Yes, this is dynamically defining classes in a module. It's a lot easier to do this in Python than when I had to write out the constant pools for Java interfaces...