Negative stats

Hello all! Question from a programming novice. Say that your character has worked hard to irritate the clergy, sinking your “devout” stat way down below zero. Negative stats work fine in the stat chart, but the game breaks when I try to work them into an *if code like the following:

*if devout < -5 The priest stares at you with contempt and horror. "I recognize you, blasphemer!" *goto excommunication *elseif (devout > -6) and (devout < 25) The priest nods distractedly when you enter the temple but otherwise ignores you. *else "Brother! Welcome back to our congregation!" The priest ushers you warmly into the sanctuary.

This doesn’t work, of course… I assume because “-” can only mean minus, not negative.

None of my tortured configurations of parentheses could get ChoiceScript to recognize a negative number in my code. My stitch-up solution has been setting the baseline “devout” score so high that no amount of sacrilege can get you below zero… but I assume there’s another way of representing negative numbers in code? Maybe something totally obvious that I’ll be embarrassed to have missed?

Yea, ChoiceScript doesn’t handle negatives well. The easiest way I can think of is to create variables for each negative number you’d like to use and set them to the right number. So at the start of the game have a series of:
*create negative_six *set negative_six 0 *set negative_six - 6
(You could also declare “negative_six = 0” in mygame.js)
Then just use the variables for checking. It’s pretty messy in terms of coding, but it should work. I think…

You should re-center your stats. As mentioned above, CS does not handle negatives well (at all).

Thanks, Jason. 200: it’s the new zero.

1 Like

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.