Jump to content

Vortex Game Support Extension issue


taytayteam1100

Recommended Posts

The script is all done execpt for one issue the mods are unpacked into the folder and the MUST be packed into a .zip or it wont work, can someone tell me what is wrong with my index.js that is causing this issue?



Note that the "Being Safe" is a change from the game name so no one can steal it .










const Promise = require('bluebird');

const path = require('path');

const { fs, log, util, api } = require('vortex-api');




// Nexus Mods domain for the game.

const GAME_ID = 'Being Safe';

//Steam Application ID.

const STEAMAPP_ID = 'Being Safe';

//GOG Application ID.

const GOGAPP_ID = 'Being Safe';


// All mods are required to end in .zip at its path directory

const MOD_FILE_EXT = ".zip";


/*

Gameversion info

Will be used to compare a mods gameversion to the

game version itself and inform users of possible

incompatibility.

const Game_version = '';

*


const GameTools = {[

{

id: GAME_ID,

name: 'Launcher',

logo: 'gameart.jpg',

executable: () => 'bin/Launcher.exe',

requiredFiles: [

'bin/Launcher.exe'

],

}

relative: true,

exclusive: true,

}

];

/*/

function installMod(files, api) {

// The .zip file is expected to always be positioned in the packs directory we're going to disregard anything placed outside the root.

const modFile = files.find(file => path.extname(file).toLowerCase() === MOD_FILE_EXT);

const idx = modFile.indexOf(path.basename(modFile));

const rootPath = path.dirname(modFile);


// Remove directories and anything that isn't in the rootPath.

const filtered = files.filter(file =>

((file.indexOf(rootPath) !== -1)

&& (!file.endsWith(path.sep))));

///

const instructions = filtered.map(file => {

return {

type: 'copy',

source: modFile,

destination: path.join(file.substr(idx)),

};

});

//*/

return Promise.resolve({

instructions,

requiredFiles: [],

api,

});

};


function testMod(files, gameId) {

// Make sure we're able to support this mod.

let supported = (gameId === GAME_ID) &&

(files.find(file => path.extname(file).toLowerCase() === MOD_FILE_EXT) !== undefined);


return Promise.resolve({

supported,

requiredFiles: [],

});

}

//*/

function prepareForModding(discovery) {

return fs.ensureDirAsync(path.join(discovery.path, 'packs'));

}


function findGame() {

try {

const instPath = winapi.RegGetValue(

'HKEY_LOCAL_MACHINE',

'SOFTWARE\\WOW6432Node\\GOG.com\\Games\\' + GOGAPP_ID,

'PATH');

if (!instPath) {

throw new Error('empty registry key');

}

return Promise.resolve(instPath.value);

} catch (err) {

return util.GameStoreHelper.findByAppId([sTEAMAPP_ID, GOGAPP_ID])

.then(game => game.gamePath);

}

}





function main(context) {

//This is the main function Vortex will run when detecting the game extension.


context.registerGame({

id: GAME_ID,

name: 'Being Safe',

mergeMods: true,

queryPath: findGame,

// supportedTools: [GameTools],

queryModPath: () => 'packs',

logo: 'gameart.jpg',

executable: () => 'bin/Being Safe_win_release.exe',

requiredFiles: [

'bin/Being Safe_win_release.exe',

'packs',

'conf'

],

setup: prepareForModding,

environment: {

SteamAPPId: STEAMAPP_ID,

GogAPPId: GOGAPP_ID,

},

details: {

steamAppId: STEAMAPP_ID,

gogAppId: GOGAPP_ID,

},

});

context.registerInstaller('Being Safe-Mod', 25, testMod, installMod);


return true

}


module.exports = {

default: main,

};

Link to comment
Share on other sites

Unfortunately Vortex doesn't offer a way to leave mod archives packed, they always get unpacked as part of the mod installation.

Thus unless the mod is double zipped (the mod archive containing another zip that's supposed to go into the mod directory) you basically have to re-zip the files Vortex hands your extension.

require('vortex-api').util contains everything you need to do that however.

 

You can look at the extension for Farming Simulator 19 which has a similar pattern: https://www.nexusmods.com/site/mods/159

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...