Variables Question

Discussion in 'Authors' Hangout' started by sexybjgal69, Nov 17, 2021.

  1. sexybjgal69

    sexybjgal69 Virgin CHYOA Backer

    Seeking help!

    I have been using variables for my Fallout New Vegas Story and I was wondering if I am just doing something wrong--or if the CHYOA website is just incapable of what I am trying to do (I am sure it is ME messing up).

    So here is my question: Can you have conditions be required between Numeric variables?

    Example: If you have 100 gold or less you can afford X. If you between 101 and 300 gold you can have get Y. If you have over 301 gold you get Z.

    I know you can do simple >= or <= but when I put a few variables what I presume is correctly (to get the Bold in particular above) it doesn't work. Help!
     
  2. Almax

    Almax Really Experienced

    Sure! You just need three chapters -- the first one requires "gold <101", the second one requires BOTH "gold >100" and "gold < 301" (you can have multiple requirements for the same variable in a chapter!), and the third one requires "gold > 300". Hope this helps!
     
    insertnamehere and gene.sis like this.
  3. insertnamehere

    insertnamehere Really Really Experienced

    I would note that mutually exclusive chapters might not be best for the situation you describe. If the player has over 300 gold, then they would expect to be able to afford their choice of X, Y or Z, perhaps if they wanted to save some money for later. If this is the chapter in question, then that's how you've currently set the chapters anyway, but if you wanted to change it then Almax is correct.

    If you mean for flavour text - that is, highlighting the most valuable item the player can afford - then you can use an if-else chain, since only one condition in such a chain will ever resolve at a time.

    If you mean a single, isolated instance of checking whether a number lies between two bounds, then you can either use an if-else chain and simply leave the text for the other conditions blank, or you can use two nested if-statements to support both conditions as described by Almax.
     
    Almax likes this.
  4. sexybjgal69

    sexybjgal69 Virgin CHYOA Backer

    Thanks for the replies!
    I will make sure to go back and try to work out the kinks.
    Insertnamehere--I just threw that gold example on there for ease. I am really using it to determine how well a combat encounter might go. If they have say less than 50 Combat strength then it goes poorly. If they have 50-75 it goes well. If they have over 75 it goes exceptionally well. etc. I really do need to use more If-statements.

    Not going to put a whole other thread out there---but is there a random chapter selector? I figure it is beyond the sites capability which is fine. But it would be interesting to throw some RNG into stories. Is there a round about way to do that?
     
  5. insertnamehere

    insertnamehere Really Really Experienced

    RNG isn't currently possible. You can use an external tool like a die and direct the reader to certain chapters based on that random result.