Write me a Vortex Extension Example for my game PILGRIM
- User
Write me a Vortex Extension Example for my game PILGRIM
- Assistant
- User
Its a steam game, so I expect I have to add that information?
- Assistant
Write me a Vortex Extension Example for my game PILGRIM
Its a steam game, so I expect I have to add that information?
Creating a Vortex extension for your game "PILGRIM" involves developing a plugin that can be managed through Vortex, the mod manager by Nexus Mods. Below, I'll provide a basic outline and example to help guide you through the process. This example assumes you have some familiarity with Vortex and modding concepts.
Set Up Your Development Environment
gulp-cli globally if you haven't already: npm install --global gulp-cli.Clone the Vortex Games GitHub Repository
git clone https://github.com/Nexus-Mods/vortex-games.git.vortex-games directory and locate the game-pilgrim folder or create one if it doesn't exist.Create Your Extension
Inside the game-pilgrim folder, you will need several key files:
Example Files
index.ts
import { IExtensionContext } from 'vortex-api/lib/types/api';
import { getGamePath } from './game';
function main(context: IExtensionContext) {
context.registerGame({
name: 'PILGRIM',
mergeMods: true,
queryPath: getGamePath,
executable: () => 'pilgrim.exe',
requiredFiles: [
'pilgrim.exe'
],
setup: (discovery) => Promise.resolve(),
});
}
export default main;
game.json
{
"name": "Pilgrim",
"author": "YourName",
"version": "1.0.0",
"gameId": "pilgrim",
"pathHint": "C:\\Program Files (x86)\\Pilgrim"
}
game.ts
import * as path from 'path';
import { fs, log } from 'vortex-api';
import * as registry from 'vortex-ext-compatibility/lib/extensions/subsystems/registry';
export const getGamePath = async () => {
try {
const gamePath = await registry.getInstallPath('PILGRIM');
return gamePath;
} catch (err) {
log('error', 'Failed to find game path for PILGRIM', { error: err.message });
throw err;
}
};
Build and Test Your Extension
gulp build to build your extension.Distribution
Creating a Vortex extension requires careful attention to detail and a good understanding of both your game's requirements and Vortex's capabilities. Customize the code above to fit the specific needs of your game "PILGRIM".
Yes, since "PILGRIM" is a Steam game, you'll need to incorporate Steam-specific integration to ensure the Vortex extension can correctly locate and manage the game installation. Here's how you can modify the extension to account for a Steam installation:
Update the game.ts File
You can use the Steam library to locate the game. To do this, you'll leverage the Steam library path to discover the installation directory of "PILGRIM". You'll need to modify the logic in getGamePath.
However, keep in mind that querying Steam directly might require additional tools or a library that can read Steam's libraryfolders.vdf configuration file. Below is a simplified example of how this could be approached:
import { fs, log } from 'vortex-api';
import * as path from 'path';
export const getGamePath = async () => {
try {
const steamLibraryPaths = [
'C:\\Program Files (x86)\\Steam\\steamapps\\common\\', // Default Steam path
// Add more possible library paths here if needed
];
// Check each library path for the game's installation
for (const libraryPath of steamLibraryPaths) {
const gamePath = path.join(libraryPath, 'PILGRIM');
if (await fs.existsAsync(gamePath)) {
return gamePath;
}
}
throw new Error('Game not found in any Steam library.');
} catch (err) {
log('error', 'Failed to find game path for PILGRIM', { error: err.message });
throw err;
}
};
Update game.json
If your game uses a unique Steam ID, such as 123456, you can include that in your game.json. This ID can be useful for automating detection via Steam tools if necessary:
{
"name": "Pilgrim",
"author": "YourName",
"version": "1.0.0",
"gameId": "pilgrim",
"steamAppId": "123456", // Replace with actual Steam App ID
"pathHint": "C:\\Program Files (x86)\\Steam\\steamapps\\common\\Pilgrim"
}
Consider Additional Tools
libraryfolders.vdf (where Steam keeps track of the different library locations).Implementing these modifications should allow your game to be managed seamlessly through Vortex while accounting for its Steam distribution. Be sure to adjust the file paths and logic according to your specific game setup and user environment.
Not yet included in a published release.