Need help with JS function defined on setup object in Sugarcube 2.37.3

Twine Version: 2.10.0
Sugarcube 2.37.3

The following is a function I have written on the setup object. Help me understand why, when I attempt to run the twine story, I get the following error:

Here’s my function:

setup.getAllIndicesOfSubstring() = function (main_string, sub_string){
  const indices = [];
  let index = main_string.indexOf(sub_string);

  while (index !== -1) {
    indices.push(index);
    index = main_string.indexOf(sub_string, index + 1);
  }

  return indices;  
};

Duh, I put “( )” in the function name. Removing them fixed the error.

1 Like