Nexus-Mods / Vortex

Vortex Development
GNU General Public License v3.0
914 stars 134 forks source link

Verify Extension: [845] Helldivers 2 Vortex Extension #15504

Closed insomnious closed 5 months ago

insomnious commented 7 months ago

Verify Extension: Helldivers 2 Vortex Extension

Use this template to verify game extensions for Vortex ​

Extension Information

Get all relevant metadata and links from nexusmods.com

Extension Name Helldivers 2 Vortex Extension
Extension Mod ID 845
Extension URL https://www.nexusmods.com/site/mods/845
Game Name Helldivers 2
Game Domain helldivers2
Game URL https://www.nexusmods.com/helldivers2

Check to see if there is an existing extension for this game

Existing Extension URL

Verification checklist

Adding extension to manifest

​ When complete, the verified extension needs adding to our manifest.

IDCs commented 6 months ago

Although the extension defines a couple of modTypes to support the game's different modding patterns; it does not include modType tests to correctly identify these mods. A custom installer will also be needed to cater for some mod packaging patterns.

To unblock:

ChemGuy1611 commented 6 months ago

Could you help me out with how to code to automatically assign modType in mod installers? I understand how to get the installer to see the .dl_bin to check if the mod is supported for the installer, but I am not certain how to assign the modType to it at that point.

Here's what I have:


const modFileExt = ".dl_bin";

function testSupportedContent(files, gameId) {
  // Make sure we're able to support this mod.
  let supported = (gameId === spec.game.id) &&
      (files.find(file => path.extname(file).toLowerCase() === modFileExt) !== undefined);

  // Test for a mod installer.
  if (supported && files.find(file =>
          (path.basename(file).toLowerCase() === 'moduleconfig.xml') &&
          (path.basename(path.dirname(file)).toLowerCase() === 'fomod'))) {
      supported = false;
  }

  return Promise.resolve({
      supported,
      requiredFiles: [],
  });
}

function installContent(files) {
  // The .fbmod 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() === modFileExt);
  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 });
}

//In the main function:

context.registerInstaller('helldivers2-dlbin', 25, testSupportedContent, installContent);
IDCs commented 6 months ago

Certainly - you can create an additional instruction in the installer like so: const setModTypeInstruction = { type: 'setmodtype', value: MODTYPE_ID }

Then just add the new instruction to the instructions array before returning the promise. instructions.push(setModTypeInstruction);

ChemGuy1611 commented 6 months ago

Got it! Updated the mod to Nexus.

IDCs commented 6 months ago

Hi again - I didn't get to test your extension yet as I can already see that the installer hasn't been tested.

function installContent(files, gameSpec) {
  <...>
  MODTYPE_ID = "helldivers2-data"; // You're missing the variable declaration!
  const setModTypeInstruction = { type: 'setmodtype', value: MODTYPE_ID };
  <...>
  instructions.push(setModTypeInstruction);
  return Promise.resolve({ instructions });
}

// declare your variable before using it:
// const/var/let MODTYPE_ID
ChemGuy1611 commented 6 months ago

Fixed and uploaded to Nexus. Just a note that I did test the code and it did work. But yes, I did add the proper declaration.