Jump to content

Issue with Game Extension I am trying to create....


kewpee
Go to solution Solved by Pickysaurus,

Recommended Posts

I am losing my mind here trying to figure out what is going wrong. Ready Or Not mod creators tend to double up their folders (ie: Folder - Folder - Mod). This makes Vortex place a folder in the mod location instead of the .pak file.

I am hoping someone can take a look at my .js file and see what the heck I did wrong because following the guide for extension creation I thought this code would ignore any folders outside of the folder containing the .pak file.

Please be my savior.  Here is my code below... it wouldn't let me attach a file in this post. 🙂

Quote
//Import some assets from Vortex we'll need.
const path = require('path');
const semver = require('semver');
const { actions, fs, log, util } = require('vortex-api');
 
// Nexus Mods domain for the game. e.g. nexusmods.com/bloodstainedritualofthenight
const GAME_ID = 'readyornot';
//Steam Application ID, you can get this from https://steamdb.info/apps/
const STEAMAPP_ID = '1144200';
//Add this to the top of the file
const winapi = require('winapi-bindings');
//Add this to the top of the file
const MOD_FILE_EXT = ".pak";
 
function findGame() {
  return util.GameStoreHelper.findByAppId([STEAMAPP_ID])
      .then(game => game.gamePath);
}
 
const oldModPath = path.join('Ready Or Not', 'Content', 'Paks');
const relModPath = path.join('ReadyOrNot', 'Content', 'Paks');
 
function prepareForModding(discovery) {
  return fs.ensureDirWritableAsync(path.join(discovery.path, relModPath),
    () => Promise.resolve());
}
 
function installContent(files) {
  // The .pak file is expected to always be positioned in the mods 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: file,
      destination: path.join(file.substr(idx)),
    };
  });
 
  return Promise.resolve({ instructions });
}
 
function testSupportedContent(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 main(context) {
    //This is the main function Vortex will run when detecting the game extension.
   
    context.registerGame({
        id: GAME_ID,
        name: 'Ready or Not 1.0',
        mergeMods: true,
        queryPath: findGame,
        supportedTools: [],
        queryModPath: () => 'ReadyOrNot/Content/Paks',
        logo: 'gameart.jpg',
        executable: () => 'ReadyOrNot.exe',
        requiredFiles: [
          'ReadyOrNot.exe',
          'ReadyOrNot/Binaries/Win64/ReadyOrNot-Win64-Shipping.exe'
        ],
        setup: prepareForModding,
        environment: {
          SteamAPPId: STEAMAPP_ID,
        },
        details: {
          steamAppId: STEAMAPP_ID,
        },
      });
   context.registerInstaller('readyornotkewp', 25, testSupportedContent, installContent);
 
    return true
}
 
module.exports = {
    default: main,
};

 

Edited by kewpee
ADDED JS INFO
Link to comment
Share on other sites

@Pickysaurus Would you be willing to help me out on this? I would really appreciate it and it would make my day. The existing Ready or Not extension that Vortex uses is broken and doesn't properly install mods into the correct location. I am making a new extension I want to submit to Nexus that others can use that will make Vortex Mod Manager usable with RoN but I cannot seem to resolve this issue I am having...

Link to comment
Share on other sites

  • Solution

If you're trying to copy only the PAK files and disregard any other files or folder structures you could try using "Stop Patterns". This means you'd remove the following parts:
 

function installContent(files) {
  // The .pak file is expected to always be positioned in the mods 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: file,
      destination: path.join(file.substr(idx)),
    };
  });
 
  return Promise.resolve({ instructions });
}
 
function testSupportedContent(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: [],
  });
}


context.registerInstaller('readyornotkewp', 25, testSupportedContent, installContent);

 

The inside the "details" part of your game registration you'd add. 

stopPatterns: ['[^|/|\\]*.pak$'],


 

Edited by Pickysaurus
Updated the stop pattern
Link to comment
Share on other sites

@Pickysaurus Thank you for such a quick reply. I messed around with stop pattern prior to trying what you saw... I kept getting an error. I just deleted everything you showed and then added the stopPatterns under details and am now getting errors when trying to delploy mods. Did I do something wrong with the code?

Quote
//Import some assets from Vortex we'll need.
const path = require('path');
const semver = require('semver');
const { actions, fs, log, util } = require('vortex-api');
 
// Nexus Mods domain for the game. e.g. nexusmods.com/bloodstainedritualofthenight
const GAME_ID = 'readyornot';
//Steam Application ID, you can get this from https://steamdb.info/apps/
const STEAMAPP_ID = '1144200';
//Add this to the top of the file
const winapi = require('winapi-bindings');
//Add this to the top of the file
const MOD_FILE_EXT = ".pak";
 
function findGame() {
  return util.GameStoreHelper.findByAppId([STEAMAPP_ID])
      .then(game => game.gamePath);
}
 
const oldModPath = path.join('Ready Or Not', 'Content', 'Paks');
const relModPath = path.join('ReadyOrNot', 'Content', 'Paks');
 
function prepareForModding(discovery) {
  return fs.ensureDirWritableAsync(path.join(discovery.path, relModPath),
    () => Promise.resolve());
}
 
function main(context) {
    //This is the main function Vortex will run when detecting the game extension.
   
    context.registerGame({
        id: GAME_ID,
        name: 'Ready or Not 1.0',
        mergeMods: true,
        queryPath: findGame,
        supportedTools: [],
        queryModPath: () => 'ReadyOrNot/Content/Paks',
        logo: 'gameart.jpg',
        executable: () => 'ReadyOrNot.exe',
        requiredFiles: [
          'ReadyOrNot.exe',
          'ReadyOrNot/Binaries/Win64/ReadyOrNot-Win64-Shipping.exe'
        ],
        setup: prepareForModding,
        environment: {
          SteamAPPId: STEAMAPP_ID,
        },
        details: {
          steamAppId: STEAMAPP_ID,
          stopPatterns: ['[^|/|\\]*.pak$'],
        },
      });
 
    return true
}
 
module.exports = {
    default: main,
};

 

Link to comment
Share on other sites

@Pickysaurus I figured it out. Working like a charm now. The code for the stopPattern is:

Quote
stopPatterns: ['(^|/).*\.pak$'],

Thank you for pointing me in the right direction! You are awesome! How do I go iabout sending this over to you guys for approval so we can get this extension to replace the outdated one? I'm excited to provide a way for people to use the Mod Manager to manage their Ready Or Not mods!

Link to comment
Share on other sites

@Pickysaurus Yeah, that extension doesn't work properly and hasn't been updated in over a year. It installs to the wrong directory and also installs a folder with the mod inside of it instead of just the .pak file. By create a page for it do you mean upload it onto Nexus website?

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...