Hello, i would like to programically read all LUA class definitions, but i only found HTML documentation at http://lua-api.factorio.com/latest/, which is not ideal data source :/ (its doable but bleh...)
has factorio some other public methods to read api (json, xml) ?
PS: im guessing that documentation HTML is generated and not hand written, so there must be some machine readable data source that can be used ...
PSS: Reason why i wanna to do this is because in trying to create mod, but currently spending 90% of time in browser searching how to write stuff (new to lua too) and also i found this: https://github.com/Perryvw/TypescriptToLua ... so im thinking about creating mod written in typescript and then transpiled to lua via node script...
Reading API documentation programically
Re: Reading API documentation programically
HTML is generated from C++ class definitions, which are not publicly available.
Lua is very easy to learn, easier than the Factorio API!
Lua is very easy to learn, easier than the Factorio API!
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Reading API documentation programically
How does cross-compiling a mod from another language help you learn the factorio api?
Re: Reading API documentation programically
So "only" thing, that needs to be done is writing generator, that will generate xml or json intead of html? --or-- make C++ class declarations (not definitions ofc) publicHTML is generated from C++ class definitions, which are not publicly available.
PS: Faster solution may be adding special html attribtues into generated html.
- for example only way i found out how to determine, that html is describing property is by looking for " :: " string as first child of <span class="attribute-type">. :/
Also property type may be spread across multiple html elements (LuaLogisticPoint or array of LuaLogisticPoint, etc.)
In typescript i can write (generate) type definition file, that will be then picked up by IDE for intellisense, so i wouldn't need to remember (search for) correct syntax for factorio api related stuff...How does cross-compiling a mod from another language help you learn the factorio api?
-
- Fast Inserter
- Posts: 128
- Joined: Wed Dec 13, 2017 1:20 pm
- Contact:
Re: Reading API documentation programically
I am betting that any time saved by this contraption would be small compared to setting it up and debuggingCzBuCHi wrote:so im thinking about creating mod written in typescript and then transpiled to lua via node script...
Re: Reading API documentation programically
probably ... but i have no idea how to debug lua using vscode ... also i dont wanna insall yet another ide for editing lua ....fiery_salmon wrote:I am betting that any time saved by this contraption would be small compared to setting it up and debuggingCzBuCHi wrote:so im thinking about creating mod written in typescript and then transpiled to lua via node script...
PS: also i think that writing type definitions for typescript will force me to learn whole factorio api anyway
Re: Reading API documentation programically
If you are using vscode, just use this already existing extension for autocompletion that also includes a script to parse the documentation: https://github.com/simonvizzini/vscode- ... er/scraper
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Re: Reading API documentation programically
i tryied that extension already, but didnt look at the code so i definely look atparser code .... thxBilka wrote:If you are using vscode, just use this already existing extension for autocompletion that also includes a script to parse the documentation: https://github.com/simonvizzini/vscode- ... er/scraper