Half-Life: Alyx Workshop Tools/Lua Scripting/Getting Started
What is VScript?
Scripting in Half-Life: Alyx is done using Lua, an easily embeddable scripting language developed by PUC Rio. Source 2 and some branches of Source 1 implement an abstraction layer known as "vscript", which allows Valve to enable scripting for games in a variety of languages including: Lua, Squirrel, GameMonkey and Python. The vscript API for Half-Life: Alyx is much more limited than that of SteamVR Home, but in the future Valve may add new functions and API features. For now, it can be rather cumbersome to add new weapons or tools.
Installation
1. Find your hlvr addon folder
- The path should looks something like: C:\Program Files (x86)\Steam\steamapps\common\Half-Life Alyx\game\hlvr_addons\<your_custom_addon_name>, depending on where you installed it.
2. Create folders
- Create a folder called: scripts. Inside that folder create another folder called: vscripts.
- you should now be in a directory that looks similar to this: C:\Program Files (x86)\Steam\steamapps\common\Half-Life Alyx\game\hlvr_addons\<your_custom_addon_name>\scripts\vscripts
Next Steps
At this point, you can begin writing scripts.
In order to load them, you'll need to move the scripts into the vscripts directory. Now they can be loaded using the script_reload_code and cl_script_reload_code console commands, which take a path to your script relative to the vscripts directory.
Starter Examples
These basic examples will show you how to connect the game world to the scripts that you write:
1. Hello Gordon: The classic example.