新手上路
什么是VScript?
在Half-Life: Alyx中编写脚本可以使用Lua——由PUC Rio开发的可以轻易嵌入到其他程序的脚本语言。起源2和起源1的一些分支有叫做“vscript”的抽象层,这就让Valve能用Lua,Squirrel,GameMonkey,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.