Howdy, Stranger!

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

Variable Continuity?

Hello guys. I'm Jinx, I just made an account for this forum, great to be here to share works and help and such.

Now my dilemma is that I have made a variable, $isfemale. It's supposed to recognize your characters' sex in my story, because it's followed up with two links, both either turning it False or True. In this case, I used 0 or 1. But for some reason, later down the line, it only recognizes the variable as true, even though I never specified that it should be.

I've included the twine file if you wish to take a look at it. I made it separate from my current work because I'm paranoid someone might take my idea, but I want you to take a look at it and tell me what I did wrong.
The Twine file I included is just me messing around with variables, trying to learn how the program works.

https://www.dropbox.com/s/ngv2w38g1a5pg1f/HelpFixThisShit.tws

I cannot thank you enough for your help.

Comments

  • In the "finalfinalresults" passage you use the JavaScript assignment operator (=) when you should have used one of the JS equality operators (==, ===).

    In other words, this:
    You are a <<if $isfemale = 1>>female<<else>>male<<endif>>
    Should be something like this: (JS lazy equality operator)
    You are a <<if $isfemale == 1>>female<<else>>male<<endif>>
    Or: (JS strict equality operator)
    You are a <<if $isfemale === 1>>female<<else>>male<<endif>>
    Or: (Twine lazy equality operator)
    You are a <<if $isfemale eq 1>>female<<else>>male<<endif>>
    Or: (Twine strict equality operator)
    You are a <<if $isfemale is 1>>female<<else>>male<<endif>>
    Since you use the Twine operators throughout the rest of the file, you might as well use them here as well.
  • I love you so much right now, thank you so much! I was absolutely confused and I was beginning to get upset at this.

    undefined
  • Is there any difference at all between lazy and strict? Apart from what you type, obviously. ;)
  • Mainly, the lazy operators perform type coercion, while the strict operators do not.  In other words, with lazy equality, as long as the values are equivalent after coercion, they're considered equal.  On the other hand, with strict equality, no coercion is performed, so the values and their types must both be equal.

    For example, testing 0 and 1 (integers) against true and false (booleans).

    Lazy equality:

    0 == true // is false
    0 == false // is true
    1 == true // is true
    1 == false // is false
    Strict equality:

    0 === true // is false
    0 === false // is false
    1 === true // is false
    1 === false // is false
    This may be informative: Comparison Operators @MDN
  • Interesting, thanks! :)
Sign In or Register to comment.