Jump to content

Photo

Vortex Game Support Extension issue


  • Please log in to reply
1 reply to this topic

#1
taytayteam1100

taytayteam1100

    Stranger

  • Members
  • Pip
  • 4 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,
  };


#2
Tannin42

Tannin42

    Resident poster

  • Staff
  • PipPipPipPipPip
  • 2,533 posts

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.nexusmod...m/site/mods/159






IPB skins by Skinbox
Page loaded in: 0.978 seconds