新手上路
Jump to navigation
Jump to search
什么是 VScript?
在 Half-Life: Alyx 中可以使用 Lua 编写脚本——由 PUC Rio 开发的可以轻易嵌入到其他程序的脚本语言。起源2和起源1的一些分支有叫做“vscript”的抽象层,这就让 Valve 能用 Lua,Squirrel,GameMonkey,Python 等语言给游戏写脚本。Half-Life: Alyx 的 VScript API 比 SteamVR Home 的受限更多,但是未来 Valve 可能还会添加一些新函数和API功能,但是添加新武器或者工具会比较痛苦且复杂。
安装
1. 找到你的 hlvr 插件文件夹
- 路径应该看起来像这样:C:\Program Files (x86)\Steam\steamapps\common\Half-Life Alyx\game\hlvr_addons\<你的自定义插件文件夹名>,取决于你把 hlvr 装哪儿了。
2. 创建文件夹
- 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.