User:Ash/SRB2 Lua on VSCode
Introduction
REPORT BUGS AND MISSING DEFINITIONS HERE: https://git.do.srb2.org/LJSonic/vscode-lua-srb2
This is a simple guide to get SRB2 Lua working on VSCode.
Thanks to LJ for making these tools available to us!
Getting it working
This guide requires VSCode to be already installed on your computer.
Follow the guide step by step for best results.
WARNING: THIS MAY REQUIRE OTHER LUA LANGUAGE EXTENSIONS TO BE DISABLED.
Download the files
First, download one of the following file depending on your OS, and decompress it:
- VSCode-SRB2Lua-3.17.1-win32-x64.zip
- VSCode-SRB2Lua-3.17.1-linux-x64.zip
- VSCode-SRB2Lua-3.17.1-darwin-x64.zip
Put the SRB2-2.2/ folder (you can rename it if you want) in a place you won't have to move very often (for best results!).
Install the VSIX file
In VSCode, open your command palette (on PC: F1 or CTRL+Shift+P. on Mac: Command+Shift+P).
Type "Install from VSIX":
Follow the prompt to install the SRB2 Lua VSIX file that matches your OS ("vscode-srb2lua-X.X.X-win32-x64.vsix" on Windows).
Configure the library path
When it's installed, go to your extensions and locate the SRB2 Lua extension.
Then, click the gear icon to open its settings.
Once in settings, scroll down until you see "Lua > Workspace: Library".
From there, hit the "Add Item" button and point it to the srb2.d.lua file.
Any other Lua files you'd like the extension to reference are OPTIONAL.
Pictured is my setup, with the srb2.d.lua file and 2 files I wanted the extension to load for me (the name is wrong in this picture):
Configure the preload limits
Since SRB2's Lua API is very expansive, you may want to scroll to find "Lua > Workspace: Max Preload" and "Lua > Workspace: Preload File Size".
From there, increase their values so the library file doesn't get rejected by the extension.
My settings are provided as a reference, but you can use any number that works (but the default is too small, I think):
Optional configuration for SRB2
Configure the plugin path
You can make the extension automatically infer the types of the arguments in `addHook()` by pointing "Lua > Runtime > Plugin" to the plugin.lua file.
Enable SRB2-specific syntax
You can optionally add SRB2 Lua specific symbols like continue and slash comments // under "Lua > Runtime: Nonstandard Symbol".
The pseudo-variable syntax ($, $1, $2, etc.) is already supported by default:
And that's it! You should be able to see it working in your Lua files:
Troubleshooting
If it does not work, try the following steps:
- Some web browsers seem to download srb2.d.lua with the wrong extension under some circumstances. Ensure it is not called srb2.d.lua.txt or some other extension instead.
- Disable any other VS Code Lua extensions you may have installed before, as they can sometimes interfere.