Difference between revisions of "HPL3/Scripting/Scripting Guide/Setting up Visual Studio Code"
(Warnings) |
|||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
| + | {{Hpl3ScriptingGuideMenuBasic}} | ||
{{shortPageTitle}} | {{shortPageTitle}} | ||
| − | |||
| − | |||
| − | + | == Visual Studio Code language support == | |
| − | + | [https://marketplace.visualstudio.com/items?itemName=TiManGames.hpl3-language-tools HPL3 Language Tools] is a community-made Visual Studio Code extension that provides language support for HPL3 <code>.hps</code> scripts. | |
| − | + | It supports: | |
| − | + | * ''SOMA'' | |
| + | * ''Amnesia: Rebirth'' | ||
| + | * ''Amnesia: The Bunker'' | ||
| − | + | The extension treats HPL3 scripts as their own AngelScript-based language instead of C++. This prevents unrelated C++ diagnostics and enables HPL3-specific completion, validation, navigation, mod overlays, and callback checking. | |
| − | + | HPL3 Language Tools is not affiliated with or endorsed by Frictional Games. The game compiler remains the final authority when validating scripts. | |
| − | + | === Installation === | |
| − | + | ==== Visual Studio Marketplace ==== | |
| − | + | # Open Visual Studio Code. | |
| + | # Open the '''Extensions''' view. | ||
| + | # Search for '''HPL3 Language Tools'''. | ||
| + | # Select the extension published by '''TiManGames'''. | ||
| + | # Click '''Install'''. | ||
| − | + | <!-- Replace this comment with the Marketplace link after publication: | |
| + | [MARKETPLACE_URL Install HPL3 Language Tools from the Visual Studio Marketplace] | ||
| + | --> | ||
| − | + | ==== Local VSIX ==== | |
| − | + | The extension can also be installed manually: | |
| − | + | # Download the latest <code>.vsix</code> package from the [https://github.com/TiManGames/hpl3-language-tools/releases GitHub releases page]. | |
| + | # Open the Visual Studio Code Command Palette with <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd>. | ||
| + | # Run '''Extensions: Install from VSIX...''' | ||
| + | # Select the downloaded file. | ||
| + | # Reload Visual Studio Code if prompted. | ||
| − | <syntaxhighlight lang=""> | + | === Opening an HPL3 project === |
| + | |||
| + | The simplest setup is to open the game installation folder as the Visual Studio Code workspace: | ||
| + | |||
| + | <pre> | ||
| + | C:\Program Files (x86)\Steam\steamapps\common\SOMA | ||
| + | C:\Program Files (x86)\Steam\steamapps\common\Amnesia Rebirth | ||
| + | C:\Program Files (x86)\Steam\steamapps\common\Amnesia The Bunker | ||
| + | </pre> | ||
| + | |||
| + | When the game folder is open, the extension normally detects the game automatically by locating: | ||
| + | |||
| + | * <code>hps_api.hps</code> | ||
| + | * <code>resources.cfg</code> | ||
| + | * The <code>script</code> directory | ||
| + | |||
| + | It is also possible to open an individual mod folder or another folder beneath the game installation. | ||
| + | |||
| + | If automatic detection fails: | ||
| + | |||
| + | # Open the Command Palette. | ||
| + | # Run '''HPL3: Select Game Root'''. | ||
| + | # Select the root folder of the appropriate HPL3 game. | ||
| + | |||
| + | The selected folder should be the main game folder, not its <code>mods</code>, <code>maps</code>, or <code>script</code> subdirectory. | ||
| + | |||
| + | === HPS language association === | ||
| + | |||
| + | Files ending in <code>.hps</code> should use the '''HPL3 HPS''' language mode. | ||
| + | |||
| + | The current language mode is displayed in the lower-right corner of Visual Studio Code. If it displays '''C++''', click it and select '''HPL3 HPS'''. | ||
| + | |||
| + | Some existing setups explicitly associate HPS files with C++: | ||
| + | |||
| + | <syntaxhighlight lang="json"> | ||
"files.associations": { | "files.associations": { | ||
"*.hps": "cpp" | "*.hps": "cpp" | ||
| Line 35: | Line 80: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| − | + | Remove that association if it prevents the extension from selecting HPL3 HPS. The extension may display a one-time warning about this configuration, but it will not modify the user's settings automatically. | |
| − | + | === Selecting an active mod === | |
| − | + | By default, <code>hpl3.activeMod</code> is set to <code>auto</code>. | |
| − | + | In automatic mode, the extension selects the mod containing the currently opened script. To select a mod explicitly: | |
| − | + | # Open the Command Palette. | |
| + | # Run '''HPL3: Select Active Mod'''. | ||
| + | # Select the desired mod. | ||
| − | + | The active mod controls script overlays, include resolution, completion, definitions, and project validation. | |
| − | + | Resolution generally follows this priority: | |
| − | + | # The directory containing the current file | |
| + | # The active mod | ||
| + | # Direct mod dependencies | ||
| + | # Deeper transitive dependencies | ||
| + | # The base game | ||
| + | # Additional configured resource roots | ||
| − | + | An active-mod file shadows a dependency or base-game file using the same virtual resource path. | |
| − | + | === Mod dependencies === | |
| − | + | The extension reads each mod's <code>entry.hpc</code> file and resolves dependencies through their exact <code>Content.UID</code> values. | |
| − | + | When mod X depends on mod Y, selecting mod X indexes: | |
| − | + | * Scripts belonging to mod X | |
| + | * Scripts belonging to mod Y | ||
| + | * Reachable transitive dependencies | ||
| + | * Base-game scripts and API declarations | ||
| − | + | Unrelated mods are excluded. | |
| − | + | ||
| − | + | Missing dependencies, duplicate UIDs, malformed manifests, and dependency cycles are reported through the HPL3 status tooltip and output channel. Valid and unambiguous dependencies continue to be indexed when possible. | |
| − | + | ||
| − | + | === Language features === | |
| − | + | ||
| − | + | HPL3 Language Tools provides: | |
| − | + | ||
| − | + | * Engine and project API completion | |
| − | + | * Class and inherited-member completion | |
| − | + | * Enum-value completion | |
| − | + | * Array and handle type inference | |
| − | + | * Include-path completion | |
| − | + | * Hover documentation | |
| − | + | * Function signature help | |
| − | + | * Go to definition | |
| − | + | * Document and workspace symbols | |
| − | + | * Include navigation | |
| − | + | * Incremental analysis while editing | |
| − | + | * Automatic reindexing when scripts are changed or saved | |
| − | + | * Semantic highlighting for HPL3 types, members, enums, and keywords | |
| − | + | ||
| − | + | Documentation and engine declarations are primarily loaded from the selected game's <code>hps_api.hps</code> file. | |
| − | + | ||
| − | + | === Diagnostics === | |
| − | + | ||
| − | + | The extension reports likely script or engine failures, including: | |
| − | + | ||
| − | + | * Malformed HPL3 or AngelScript syntax | |
| − | + | * Unresolved or ambiguous includes | |
| − | + | * Unknown variables, functions, types, or members | |
| − | + | * Duplicate declarations in the same scope | |
| − | + | * Invalid assignments and primitive conversions | |
| − | + | * Invalid return values | |
| − | + | * Incorrect constructor arguments | |
| − | + | * Missing function arguments | |
| − | + | * Invalid overload calls | |
| − | + | * Callback names that cannot be resolved | |
| − | + | * Callback signature mismatches | |
| − | + | * Unsupported dialect operations such as <code>array.clear()</code> | |
| + | |||
| + | Callback and mutable-global checks that can be valid in dynamic HPL3 code are generally displayed as warnings. | ||
| + | |||
| + | The extension intentionally does not enforce: | ||
| − | + | * C++ formatting conventions | |
| + | * Naming conventions | ||
| + | * Include guards | ||
| + | * Pointer style | ||
| + | * Unused-variable rules | ||
| + | * Other C++-specific style diagnostics | ||
| − | + | To validate every indexed script rather than only open or affected files, run '''HPL3: Validate Workspace'''. | |
| − | + | === Running the current map === | |
| − | + | A '''Run Map''' CodeLens and editor-title play button appear when an HPS map script has a matching <code>.hpm</code> or legacy <code>.map</code> asset. | |
| − | + | To launch the map: | |
| − | + | # Open the map's <code>.hps</code> script. | |
| + | # Click '''Run Map''' above the map class, or click the play icon in the editor title. | ||
| + | # The extension saves modified workspace files. | ||
| + | # The selected game starts in developer mode with the resolved map and mod arguments. | ||
| − | + | The map is resolved through the active-mod, dependency, and base-game overlays. A script-only mod override can therefore launch a map asset supplied by a dependency or the base game. | |
| − | + | Launch details are written to the '''HPL3 Map Launcher''' output channel. | |
| − | + | The extension directly launches the game executable. It does not create or modify development batch files. | |
| − | + | === Commands === | |
| − | = | + | {| class="wikitable" |
| + | ! Command | ||
| + | ! Description | ||
| + | |- | ||
| + | | '''HPL3: Select Game Root''' | ||
| + | | Selects the SOMA, Rebirth, or Bunker installation used for indexing. | ||
| + | |- | ||
| + | | '''HPL3: Select Active Mod''' | ||
| + | | Selects the active mod and its dependency profile. | ||
| + | |- | ||
| + | | '''HPL3: Rebuild Language Index''' | ||
| + | | Discards existing caches and reindexes the API, resources, and scripts. | ||
| + | |- | ||
| + | | '''HPL3: Validate Workspace''' | ||
| + | | Runs diagnostics across the complete indexed project. | ||
| + | |- | ||
| + | | '''HPL3: Run Current Map''' | ||
| + | | Launches the map associated with the current script. | ||
| + | |} | ||
| − | + | === Settings === | |
| − | + | {| class="wikitable" | |
| + | ! Setting | ||
| + | ! Default | ||
| + | ! Description | ||
| + | |- | ||
| + | | <code>hpl3.gameRoot</code> | ||
| + | | Automatic | ||
| + | | Absolute path to a supported HPL3 game installation. | ||
| + | |- | ||
| + | | <code>hpl3.activeMod</code> | ||
| + | | <code>auto</code> | ||
| + | | Automatically detected or explicitly selected active mod. | ||
| + | |- | ||
| + | | <code>hpl3.extraResourceRoots</code> | ||
| + | | <code>[]</code> | ||
| + | | Additional read-only resource roots searched after mod and base-game resources. | ||
| + | |- | ||
| + | | <code>hpl3.diagnostics.maxPerFile</code> | ||
| + | | <code>100</code> | ||
| + | | Maximum number of diagnostics displayed in one file. | ||
| + | |- | ||
| + | | <code>hpl3.trace.server</code> | ||
| + | | <code>off</code> | ||
| + | | Controls language-server protocol logging. | ||
| + | |- | ||
| + | | <code>hpl3.launch.executable</code> | ||
| + | | Automatic | ||
| + | | Optional game executable override. | ||
| + | |- | ||
| + | | <code>hpl3.launch.user</code> | ||
| + | | <code>Dev</code> | ||
| + | | Developer user passed to the game. | ||
| + | |- | ||
| + | | <code>hpl3.launch.config</code> | ||
| + | | <code>config/main_init_dev.cfg</code> | ||
| + | | Developer configuration passed to the game. | ||
| + | |- | ||
| + | | <code>hpl3.launch.extraArgs</code> | ||
| + | | <code>[]</code> | ||
| + | | Additional arguments appended to the map-launch command. | ||
| + | |} | ||
| − | + | === Troubleshooting === | |
| − | + | ==== Completion is not displayed ==== | |
| − | |||
| − | / | + | * Confirm that the file language mode is '''HPL3 HPS'''. |
| + | * Remove any explicit <code>"*.hps": "cpp"</code> file association. | ||
| + | * Verify that the correct game and mod appear in the HPL3 status tooltip. | ||
| + | * Run '''HPL3: Rebuild Language Index'''. | ||
| − | + | ==== The project is marked as degraded ==== | |
| − | + | Open '''View: Toggle Output''' and select the '''HPL3 Language Server''' channel. | |
| − | + | A degraded project can be caused by: | |
| − | + | * A missing or malformed <code>hps_api.hps</code> | |
| − | + | * A malformed <code>entry.hpc</code> | |
| + | * Missing or duplicate dependency UIDs | ||
| + | * Dependency cycles | ||
| + | * Invalid resource configuration | ||
| − | + | When API indexing is degraded, the extension suppresses unreliable unknown-engine-symbol diagnostics to avoid excessive false errors. | |
| − | + | ==== The wrong helper definition is selected ==== | |
| − | + | Use '''HPL3: Select Active Mod''' and confirm the intended top-level mod. The active mod shadows dependency and base-game resources using the same virtual path. | |
| − | + | ==== Run Map is unavailable ==== | |
| − | + | Confirm that: | |
| − | + | * The current file is an HPS map script. | |
| + | * A matching <code>.hpm</code> or <code>.map</code> asset exists. | ||
| + | * The map is reachable through the selected mod profile. | ||
| + | * The correct game root is selected. | ||
| − | + | === Platform support === | |
| − | + | Windows is the officially supported platform. | |
| − | + | Language-server features may work on Linux when <code>hpl3.gameRoot</code> points to a Steam/Proton installation. Linux is not currently tested, and '''Run Map''' is Windows-only because it directly detects and launches the Windows game executables. | |
| − | + | === Source code and bug reports === | |
| − | + | Source code, releases, and issue tracking are available at: | |
| − | + | * [https://github.com/TiManGames/hpl3-language-tools TiManGames/hpl3-language-tools] | |
| − | + | * [https://github.com/TiManGames/hpl3-language-tools/issues Report a bug or request a feature] | |
| − | + | {{NavBar|HPL3/Scripting/Scripting_Guide/What is scripting in HPL3?|What is scripting in HPL3?|HPL3/Scripting/HPL3 Scripting Guide|HPL3 Scripting Guide|HPL3/Scripting/Scripting_Guide/Scripting Workflow and Structure|Scripting Workflow and Structure}} | |
| − | + | [[Category:HPL3 Scripting]] | |
| + | [[Category:English]] | ||
Latest revision as of 00:18, 31 July 2026
Contents
- 1 Visual Studio Code language support
Visual Studio Code language support
HPL3 Language Tools is a community-made Visual Studio Code extension that provides language support for HPL3 .hps scripts.
It supports:
- SOMA
- Amnesia: Rebirth
- Amnesia: The Bunker
The extension treats HPL3 scripts as their own AngelScript-based language instead of C++. This prevents unrelated C++ diagnostics and enables HPL3-specific completion, validation, navigation, mod overlays, and callback checking.
HPL3 Language Tools is not affiliated with or endorsed by Frictional Games. The game compiler remains the final authority when validating scripts.
Installation
Visual Studio Marketplace
- Open Visual Studio Code.
- Open the Extensions view.
- Search for HPL3 Language Tools.
- Select the extension published by TiManGames.
- Click Install.
Local VSIX
The extension can also be installed manually:
- Download the latest
.vsixpackage from the GitHub releases page. - Open the Visual Studio Code Command Palette with Ctrl+Shift+P.
- Run Extensions: Install from VSIX...
- Select the downloaded file.
- Reload Visual Studio Code if prompted.
Opening an HPL3 project
The simplest setup is to open the game installation folder as the Visual Studio Code workspace:
C:\Program Files (x86)\Steam\steamapps\common\SOMA C:\Program Files (x86)\Steam\steamapps\common\Amnesia Rebirth C:\Program Files (x86)\Steam\steamapps\common\Amnesia The Bunker
When the game folder is open, the extension normally detects the game automatically by locating:
hps_api.hpsresources.cfg- The
scriptdirectory
It is also possible to open an individual mod folder or another folder beneath the game installation.
If automatic detection fails:
- Open the Command Palette.
- Run HPL3: Select Game Root.
- Select the root folder of the appropriate HPL3 game.
The selected folder should be the main game folder, not its mods, maps, or script subdirectory.
HPS language association
Files ending in .hps should use the HPL3 HPS language mode.
The current language mode is displayed in the lower-right corner of Visual Studio Code. If it displays C++, click it and select HPL3 HPS.
Some existing setups explicitly associate HPS files with C++:
"files.associations": {
"*.hps": "cpp"
}
Remove that association if it prevents the extension from selecting HPL3 HPS. The extension may display a one-time warning about this configuration, but it will not modify the user's settings automatically.
Selecting an active mod
By default, hpl3.activeMod is set to auto.
In automatic mode, the extension selects the mod containing the currently opened script. To select a mod explicitly:
- Open the Command Palette.
- Run HPL3: Select Active Mod.
- Select the desired mod.
The active mod controls script overlays, include resolution, completion, definitions, and project validation.
Resolution generally follows this priority:
- The directory containing the current file
- The active mod
- Direct mod dependencies
- Deeper transitive dependencies
- The base game
- Additional configured resource roots
An active-mod file shadows a dependency or base-game file using the same virtual resource path.
Mod dependencies
The extension reads each mod's entry.hpc file and resolves dependencies through their exact Content.UID values.
When mod X depends on mod Y, selecting mod X indexes:
- Scripts belonging to mod X
- Scripts belonging to mod Y
- Reachable transitive dependencies
- Base-game scripts and API declarations
Unrelated mods are excluded.
Missing dependencies, duplicate UIDs, malformed manifests, and dependency cycles are reported through the HPL3 status tooltip and output channel. Valid and unambiguous dependencies continue to be indexed when possible.
Language features
HPL3 Language Tools provides:
- Engine and project API completion
- Class and inherited-member completion
- Enum-value completion
- Array and handle type inference
- Include-path completion
- Hover documentation
- Function signature help
- Go to definition
- Document and workspace symbols
- Include navigation
- Incremental analysis while editing
- Automatic reindexing when scripts are changed or saved
- Semantic highlighting for HPL3 types, members, enums, and keywords
Documentation and engine declarations are primarily loaded from the selected game's hps_api.hps file.
Diagnostics
The extension reports likely script or engine failures, including:
- Malformed HPL3 or AngelScript syntax
- Unresolved or ambiguous includes
- Unknown variables, functions, types, or members
- Duplicate declarations in the same scope
- Invalid assignments and primitive conversions
- Invalid return values
- Incorrect constructor arguments
- Missing function arguments
- Invalid overload calls
- Callback names that cannot be resolved
- Callback signature mismatches
- Unsupported dialect operations such as
array.clear()
Callback and mutable-global checks that can be valid in dynamic HPL3 code are generally displayed as warnings.
The extension intentionally does not enforce:
- C++ formatting conventions
- Naming conventions
- Include guards
- Pointer style
- Unused-variable rules
- Other C++-specific style diagnostics
To validate every indexed script rather than only open or affected files, run HPL3: Validate Workspace.
Running the current map
A Run Map CodeLens and editor-title play button appear when an HPS map script has a matching .hpm or legacy .map asset.
To launch the map:
- Open the map's
.hpsscript. - Click Run Map above the map class, or click the play icon in the editor title.
- The extension saves modified workspace files.
- The selected game starts in developer mode with the resolved map and mod arguments.
The map is resolved through the active-mod, dependency, and base-game overlays. A script-only mod override can therefore launch a map asset supplied by a dependency or the base game.
Launch details are written to the HPL3 Map Launcher output channel.
The extension directly launches the game executable. It does not create or modify development batch files.
Commands
| Command | Description |
|---|---|
| HPL3: Select Game Root | Selects the SOMA, Rebirth, or Bunker installation used for indexing. |
| HPL3: Select Active Mod | Selects the active mod and its dependency profile. |
| HPL3: Rebuild Language Index | Discards existing caches and reindexes the API, resources, and scripts. |
| HPL3: Validate Workspace | Runs diagnostics across the complete indexed project. |
| HPL3: Run Current Map | Launches the map associated with the current script. |
Settings
| Setting | Default | Description |
|---|---|---|
hpl3.gameRoot
|
Automatic | Absolute path to a supported HPL3 game installation. |
hpl3.activeMod
|
auto
|
Automatically detected or explicitly selected active mod. |
hpl3.extraResourceRoots
|
[]
|
Additional read-only resource roots searched after mod and base-game resources. |
hpl3.diagnostics.maxPerFile
|
100
|
Maximum number of diagnostics displayed in one file. |
hpl3.trace.server
|
off
|
Controls language-server protocol logging. |
hpl3.launch.executable
|
Automatic | Optional game executable override. |
hpl3.launch.user
|
Dev
|
Developer user passed to the game. |
hpl3.launch.config
|
config/main_init_dev.cfg
|
Developer configuration passed to the game. |
hpl3.launch.extraArgs
|
[]
|
Additional arguments appended to the map-launch command. |
Troubleshooting
Completion is not displayed
- Confirm that the file language mode is HPL3 HPS.
- Remove any explicit
"*.hps": "cpp"file association. - Verify that the correct game and mod appear in the HPL3 status tooltip.
- Run HPL3: Rebuild Language Index.
The project is marked as degraded
Open View: Toggle Output and select the HPL3 Language Server channel.
A degraded project can be caused by:
- A missing or malformed
hps_api.hps - A malformed
entry.hpc - Missing or duplicate dependency UIDs
- Dependency cycles
- Invalid resource configuration
When API indexing is degraded, the extension suppresses unreliable unknown-engine-symbol diagnostics to avoid excessive false errors.
The wrong helper definition is selected
Use HPL3: Select Active Mod and confirm the intended top-level mod. The active mod shadows dependency and base-game resources using the same virtual path.
Confirm that:
- The current file is an HPS map script.
- A matching
.hpmor.mapasset exists. - The map is reachable through the selected mod profile.
- The correct game root is selected.
Platform support
Windows is the officially supported platform.
Language-server features may work on Linux when hpl3.gameRoot points to a Steam/Proton installation. Linux is not currently tested, and Run Map is Windows-only because it directly detects and launches the Windows game executables.
Source code and bug reports
Source code, releases, and issue tracking are available at: