Factorio API autocomplete extension for Visual Studio Code

Place to post guides, observations, things related to modding that are not mods themselves.
ibeatbabybiters
Inserter
Inserter
Posts: 30
Joined: Sun Apr 30, 2017 7:14 pm
Contact:

Factorio API autocomplete extension for Visual Studio Code

Post by ibeatbabybiters »

Hello,

I've recently bought the game and wanted to start modding, but first I wanted to make life easier by having the official API documentation inside my editor. And so I've created a VS Code extension that provides autocompletion for the Factorio API.

Features:
  • Autocomplete of all Lua classes and globals
Image
Image
  • Mouse hover tooltips
It can be installed directly in VS Code by searching for "factorio" in the extension gallery.
Marketplace: https://marketplace.visualstudio.com/it ... tocomplete
Github: https://github.com/simonvizzini/vscode- ... tocomplete

VS Code is free and open source, by the way!

Feedback welcome! The extension still requires some polishing so there may be some quirks here and there. Especially the formatting of the documentation is a bit wonky, because converting HTML to plain text is a bit difficult and I don't think I'll be able to improve it much more. Best solution would be to have the API documentation available in another format than HTML, but the dev's would need to provide that (I'm not sure how they generate their API docs). At least it was quite fun to try this web scraping stuff for once.

If you want to contribute then feel free to create a pull request, report bugs or just make a suggestion :)

Happy modding!
Last edited by ibeatbabybiters on Sun Jun 04, 2017 4:45 pm, edited 3 times in total.
Usually I don't beat babies, but when I do I beat baby biters.
User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2638
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: Factorio API autocomplete extension for Visual Studio Code

Post by steinio »

Nice, i will try it out.

Greetings, steinio.
Image

Transport Belt Repair Man

View unread Posts
ibeatbabybiters
Inserter
Inserter
Posts: 30
Joined: Sun Apr 30, 2017 7:14 pm
Contact:

Re: Factorio API autocomplete extension for Visual Studio Code

Post by ibeatbabybiters »

Heya,

I've released a new version with some new features and improvements! See first post, I'll keep it updated in the future.
Usually I don't beat babies, but when I do I beat baby biters.
User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2638
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: Factorio API autocomplete extension for Visual Studio Code

Post by steinio »

ibeatbabybiters wrote:Heya,

I've released a new version with some new features and improvements! See first post, I'll keep it updated in the future.
Hi,

funny that VS C notified me already about an update.
The whole app seems a bit wonky but that's not your fault.

I believe the new settings api is not implemented now?
Greetings, steinio.
Image

Transport Belt Repair Man

View unread Posts
AndrewIRL
Fast Inserter
Fast Inserter
Posts: 240
Joined: Fri Mar 24, 2017 2:17 pm
Contact:

Re: Factorio API autocomplete extension for Visual Studio Code

Post by AndrewIRL »

Impressive
ibeatbabybiters
Inserter
Inserter
Posts: 30
Joined: Sun Apr 30, 2017 7:14 pm
Contact:

Re: Factorio API autocomplete extension for Visual Studio Code

Post by ibeatbabybiters »

@steinio: The new settings API should be there, though it's currently not offering autocomplete for the global "setting" word, instead you'd have to type "LuaSetting" for now to get autocomplete. I'll add it as a global in the next update. Also documentation (http://lua-api.factorio.com/latest/LuaSettings.html) is currently missing and seems to be only available in the stickied feedpack post for now. Once it's in the API docs it will be also available in the extension.

What I'd like to also implement is some kind of setting so users can define their own global triggers, for example if you have functions like:

Code: Select all

function doSomethingWithTrain(myTrain) -- myTrain is of type LuaTrain
    myTrain....
end
you'd get no autocomplete for "myTrain" because there is no way to know what type "myTrain" actually is. So eventually it will be possible to add a custom trigger which would then give suggestions for "LuaTrain" if it detects the "myTrain" word. This would be mainly useful if you have multiple functions that take certain types with fixed names. It's not a perfect solution but at least better than nothing.

@AndrewIRL: Thanks! =)
Usually I don't beat babies, but when I do I beat baby biters.
User avatar
Dustine
Long Handed Inserter
Long Handed Inserter
Posts: 60
Joined: Tue Mar 31, 2015 4:52 pm
Contact:

Re: Factorio API autocomplete extension for Visual Studio Code

Post by Dustine »

Thank you!! Nexela pointed me to this post and this does about exactly what I've been wanting all along (specially if you count your wishlist features :D)
ibeatbabybiters
Inserter
Inserter
Posts: 30
Joined: Sun Apr 30, 2017 7:14 pm
Contact:

Re: Factorio API autocomplete extension for Visual Studio Code

Post by ibeatbabybiters »

Just wanted to say I haven't stopped working on this, I just got so much other stuff to do lately, like finally playing the 0.15 update :D I've made some improvements which I need to finish, like converting the docs into markdown with clickable links to the official docs etc, but it's far from perfect. Parsing the HTMl is kinda messy and no fun. i think I'm doing it wrong =/
Usually I don't beat babies, but when I do I beat baby biters.
ibeatbabybiters
Inserter
Inserter
Posts: 30
Joined: Sun Apr 30, 2017 7:14 pm
Contact:

Re: Factorio API autocomplete extension for Visual Studio Code

Post by ibeatbabybiters »

I spent another evening trying to parse that stupid HTML and it's still a mess but I'm happy with the result. Tooltips are now fully markdown formatted, with links to the official api docs. It's not perfect but I'm not gonna touch that anytime soon again.

Also class inheritance is now considered, so for example properties of type LuaEntity will now also offer suggestions from its parent class LuaControl. Also I managed to scrape all the LuaControlBehavior types.

I think, now I'm ready to write my first mod :D

Happy modding and let me know if you experience any issues.
Usually I don't beat babies, but when I do I beat baby biters.
unobtanium
Inserter
Inserter
Posts: 31
Joined: Fri Nov 04, 2016 11:58 am
Contact:

Re: Factorio API autocomplete extension for Visual Studio Code

Post by unobtanium »

Hey, any chance of updating this to the newest version of Factorio?
Or maybe providing some sort of guide on how to generate a new version from the API documentation myself and others? That would be great! :)
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Factorio API autocomplete extension for Visual Studio Code

Post by darkfrei »

Is it possible to make it as Notepad++ plugin?
Roang
Inserter
Inserter
Posts: 27
Joined: Tue Aug 22, 2017 12:38 pm
Contact:

Re: Factorio API autocomplete extension for Visual Studio Code

Post by Roang »

I've updated the extension with the latest data, the version is available as download at: https://github.com/Roang-zero1/vscode-f ... /releases/

I've also updated the Readme of the extension to show how to update the data on your own.
Post Reply

Return to “Modding discussion”