tmedwards / sugarcube-2

SugarCube is a free (gratis and libre) story format for Twine/Twee.
https://www.motoslave.net/sugarcube/2/
BSD 2-Clause "Simplified" License
185 stars 42 forks source link

Error message when playing story #335

Closed BetaTypeCoda closed 2 months ago

BetaTypeCoda commented 2 months ago

Describe the bug. It opens my browser, but an error message appears and I'm unable to do anything. My stories are made from templates I got from Itch.io, so part of the problem might be them being out of date.

On one of the templates I use, someone was also having the same issues, but they managed to fix it and posted a way to fix it. So far it seems to work but it displays a different error saying, 'config is not defined'. The person suggested to change 'config' to 'Config' in JavaScript to which I did but got this message.

Screenshot 2024-09-12 145049

To Reproduce: Steps to reproduce the behavior:

  1. I use the Twine/Sugarcube 2 Template by a.w. morgan on Itch.
  2. Importing it into Twine then playing it will give the error message about the ID 'story' in the interface.
  3. Replace every ID 'story' and #story with 'mystory'.
  4. After that it'll say, 'config is not defined'.
  5. Change 'config' to 'Config' in 'config.saves.autosave = "autosave";' to make the error like in the screenshot to appear.

Expected behavior. Run games.

Screenshots. Screenshot 2024-09-12 145038 Screenshot 2024-09-12 145131

Project details.

Desktop details.

Additional context. I use story templates from Itch.io. So, I'm thinking them being out of date is the issue.

greyelf commented 2 months ago

@BetaTypeCoda Because you are now using a 2.37.x version of SugarCube to build your project I strongly suggest you read the Updating to any version ≥2.37.0 from a lesser version section of the SugarCube documentation, as it contains answers to your reported issues.

tmedwards commented 2 months ago

↑ That. Greyelf has the right of it.

Additionally. You have config.saves.autosave in there twice, with different values no less. It is not helpful to have multiple versions of the same configuration value.

Assuming you want the second version, because that's the version that's taking effect now, you want something like this:

Config.saves.maxAutoSaves = 1;
Config.saves.isAllowed = function (saveType) {
    return !tags().includes('noreturn');
};

And as to the second error you received, it tells you exactly what's wrong. It's coming from the first version you have:

config.saves.autosave = "autosave";

Is "autosave" any of the types listed in the error? No. It's neither a boolean (true or false), an Array<string> (array of strings), a function, or a nullish value (null or undefined). It is a string value, which the error also tells you. Hence, the error.