Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

NaN appearing when I insert a variable

So, when I was doing a story, I set a variable like this:

<<set $Knowledge to $Knowledge += 1>>

But when I wrote $Knowledge, it comes out as NaN. Literally says NaN! Why?

I don't do Sugarcube 2, as I use the online version. Thanks.

This is what it looks like:
<<set $Knowledge to $Knowledge += 1>>

You now have $Knowledge!

Comments

  • edited August 2015
    You're not initialising $Knowledge. "+= 1" adds 1 to the existing value of Knowledge, so you're trying to add it to a variable that does not exist.

    In your StoryInit passage, place <<set $Knowledge to 0>>

    You want to do this for every variable.
  • Thanks! I think I have missed that. I'm the forgetful sort, heh. Thanks for taking the time to answer my stupid and obvious question.
  • Claretta wrote: »
    In your StoryInit passage, place <<set $Knowledge to 0>>

    You want to do this for every variable.
    To be specific, Claretta meant that you should initialize your $variables, not necessarily set them all to 0.
Sign In or Register to comment.