This article relates to the game "半衰期:爱莉克斯". Click here for more information.
这篇条目有关 Half-Life: Alyx 创意工坊工具集。如需详情,点击这里。
这篇条目有关 Source 2引擎。如需详情,点击这里。

新手上路

From Valve Developer Community
Jump to navigation Jump to search
English (en)中文 (zh)Translate (Translate)

什么是 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. 创建文件夹

  • 创建一个叫做“scripts”的文件夹,在里面再创建一个叫做“vscripts”的文件夹。
  • 你现在应该在一个类似这样的文件夹:C:\Program Files (x86)\Steam\steamapps\common\Half-Life Alyx\game\hlvr_addons\<你的自定义插件文件夹名>\scripts\vscripts

接下来

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.

See More Examples Here

Lua Scripting