Nucleus handler tools › Docs › Checks

An option compared as a number or boolean

Warningoption-compareA Nucleus check · Probably wrong: Nucleus runs it, but not the way you meant.

Why it matters

When the player starts from a saved profile, Nucleus gives every Game.AddOption value back as text: 4 becomes "4", true becomes "True". So === 4, == true and case 4: never match, and "False" counts as true in an if.

Example

✗ Wrong

Game.AddOption("Players", "", "players", ["2", "4"]);
Game.Play = function () {
  if (Context.Options["players"] === 4) {
    Context.StartArguments = "-four";
  }
};

✓ Right

Game.AddOption("Players", "", "players", ["2", "4"]);
Game.Play = function () {
  if (Context.Options["players"] == "4") {
    Context.StartArguments = "-four";
  }
};

How to fix it

Compare with text ("4", "Yes") or with ==, which matches "4" and 4; give yes/no options text values such as "Yes" and "No". The quick fix changes === to ==.

Turn it off, or change how it shows

Each check can be shown as an error, warning, info or hint, or turned off. VS Code: "splitscreenme.lint.rules": { "option-compare": "off" } in your settings. Notepad++: Plugins › Nucleus Co-op handlers › Settings. Command line: ncdev lint --rule option-compare=off. Other editors: the lint.rules setting of ncdev lsp.

Is this right? Tell us what's wrong
Stuck, or not sure? Ask other handler authors: Discordr/nucleuscoop