Scrap Mechanic

Scrap Mechanic

ScriptableComputer
 This topic has been pinned, so it's probably important
FlooferLand 14 Feb, 2023 @ 9:06am
VS Code integration? & I made autocompletion for this mod!
1. For players (and developers):
I've took the job of making an API declaration file myself, using the relevant bits from the ScriptableComputers guide.

This allows you to get autocompletion in most IDEs (VSCode for example) by simply requiring in my file:
require "scriptable_computers"

The file/code
You can view and download my file at a Github repository I've made for ScriptableComputer: https://github.com/FlooferLand/ScriptableComputerUtils
Feel free to contribute any changes, i plan to continue updating it if this mod updates.

I've also fixed some of the grammar in the API documentation.
Every function has a declaration containing argument and return types.

However..
There is still not any native Visual Studio Code support in this mod.
The way i currently do it is by making a new VSCode project, making a file called `script.lua`, and adding in my `scriptable_computers.lua` file and requiring it in. Then copy/pasting in my code from `script.lua` into the Script panel.

This is all just a bandage solution over using VSCode in this mod, so the mod developers themselves would need to implement proper VSCode support. (Which is covered in the next section)


2. For the mod developers:
Hi! I've been wondering if there could be some form of Visual Studio Code integration for this mod.
I'm not sure how the mod works so i can't try to implement this myself since the mod appears to not be open-source, and I lack knowledge in terms of complex Scrap Mechanic addons.

The details:
One way this could (possibly) be done is by having a "Open in Code" button in the Script interface.
When clicked, it could save the current code into a temporary file somewhere (example: "%LocalAppData%\Axolot Games\Scrap Mechanic\Temp\script.lua")
Then calling the following shell command to open the script inside VSCode:
code "%LocalAppData%\Axolot Games\Scrap Mechanic\Temp\script.lua"

This alone should already help on it's own, as there is already plenty Lua linter extensions for VSCode
Of-course, there would be additional things that would need to be done. Such as updating the in-game script when the script file is saved in VSCode.

You guys can also additionally make it so the client downloads my API reference file[raw.githubusercontent.com] and puts it along-side the player's `script.lua` file to more easily get autocompletion
Last edited by FlooferLand; 14 Feb, 2023 @ 12:40pm
< >
Showing 1-1 of 1 comments
Tomek 12 Nov, 2023 @ 2:00pm 
good work
< >
Showing 1-1 of 1 comments
Per page: 1530 50