This article relates to the game "Half-Life: Alyx". Click here for more information.
This article relates to the workshop tools for "Half-Life: Alyx". Click here for more information.
This article's documentation is for Source 2. Click here for more information.

Half-Life: Alyx Workshop Tools/Lua Scripting/Getting Started

From Valve Developer Community
< Half-Life: Alyx Workshop Tools‎ | Lua Scripting
Revision as of 17:46, 22 May 2020 by McNutty (talk | contribs) (Starter Examples)
Jump to: navigation, search

What is Lua?

Lua is a programming language frequently used in games running on the source engine. Lua scripts are able to talk to the game engine through an API layer, which allows people to create new scripts for weapons, gammemodes and much more.

  • NOTE: Due to Half Life Alyx being a fairly new game, some of the API functionality simply does not exist yet on the engine side. For example, you may encounter some API calls that will simply return nil instead of what you were expecting.

Create a Place For Your Scripts

1. Find your hlvr folder

  • The path should looks something like: D:\SteamLibrary\steamapps\common\Half-Life Alyx\game\hlvr, 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 like this: D:\SteamLibrary\steamapps\common\Half-Life Alyx\game\hlvr\scripts\vscripts

This is where all your .lua files will go

Source looks for the scripts in the scripts/vscripts folder. You can also add folders in scripts/vscripts to separate out your scripts by project or have common scripts.

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.

Example Index

Half-Life: Alyx Lua Scripting Examples