Story works in debug but published .html does not?

0 votes
asked Jan 7 by Hedge (120 points)

I'm totally new to twine, and I have encountered a strange problem.

First, I'm using twine 2.2.1 and sugarcube 2.22.0.

I have started to create a story and so far, it works well inside twine, the debug mode doesn't show any issues, everything works as I intended.

However, if I publish the file to .html, it only works until the first set of scripts, where I get the following error message:

 error within contents (Error: <<set>>: bad evaluation: undefined is not a function)

Unfortunately, I'm not knowledgeable in html (or coding in general), so I can't work out what the problem is. I hoped that whatever works in debug mode will also work after exporting. If this is not the case, I'll seriously reconsider using twine, as I don't want to lose hours of work just to realise that after publishing it won't even work anymore.

Do you have any idea how to solve this or what the problem may be? If needed, I can upload the file.

2 Answers

0 votes
answered Jan 7 by TheMadExile (32,880 points)
It very likely has nothing to do with Test mode.  If it doesn't work after Publishing, then you're probably picking up something from within the IDE which isn't a part of SugarCube; thus the issue with the published story.

We will, obviously, need to see the relevant code to be able to help.
commented Jan 7 by Hedge (120 points)

OK, here's a link to the file (this is the file from the twine library, not the published .html):

0 votes
answered Jan 7 by greyelf (58,490 points)

There are a number of issues with the way you are setting the values of your $world_nature_roll, $exotic_shape_roll and $world_origin_roll variables.

1. There should no white-space characters between a function's name and the open parentheses.

BAD:  either (param1, param2)

GOOD: either(param1, param2)

2. The either() function's documentation demonstrates the usage of that function, it makes no mention of using a .... operator to generate a list of parameter values.

3. either() is the wrong function to generate a random integer between 1 and 100, you should be using the random() function to do that.

<<set $world_nature_roll to random(1, 100)>>

<<set $exotic_shape_roll to random(1, 100)>>

<<set $world_origin_roll to random(1, 100)>>


commented Jan 7 by Hedge (120 points)
Ah, great, thanks a lot!
commented Jan 7 by TheMadExile (32,880 points)


  • Closing macro tags in the <<end…>> style are deprecated, you should be using <</…>> style tags.
  • You do not need to compare a boolean value to one of the boolean literals—i.e. true, false.  Conditional expressions ultimately resolve to a boolean value, so if your variable contains a boolean value, you may simply use it as-is in the conditional.  For example:

    // BAD
    $redgiant is true
    $redgiant is false
    // GOOD
    not $redgiant


Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.