0 votes
by (120 points)
Hi,

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
by (68.6k 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.
by (120 points)

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

https://www.dropbox.com/s/2f4ia3nowjakw20/World%20generator.html?dl=0

0 votes
by (159k 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)>>

 

by (120 points)
Ah, great, thanks a lot!
by (68.6k points)

Additionally:

  • 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
    $redgiant
    not $redgiant

     

...