Game book scripting question: Comparing a counter to another counter?

Shius
21 Nov 2016, 06:00So what I want to do is very simple. I am making a gamebook for a concept game I have in mind, where, if you die, you get to see your stats and achievements you've made along the way.
One thing I've implemented is compare counter objects. So, if one counter object is higher then an opposing counter, then it should show something like,
"You were more brave than you were cautious."
And that's just not working.
I thought I'd succeed with a rather simple if statement, but it just. Doesn't. Save. This is the code I have in mind:
if (GetInt(game, "riskTaker") > GetInt(game, "cautious")) {
PrintCentered ("[Achievement Earned: You were a Risk Taker.]<br/>")
}
else if (GetInt(game, "riskTaker") < GetInt(game, "cautious")) {
PrintCentered ("[Achievement Earned: You were Cautious.]<br/>")
}
else {
//some other message I haven't decided on yet
}
Whenever I type this in, with the second counter as an expression, it runs the game once perfectly, I might add - and then once I save the file a second time it disappears, giving me an error with the following words:
Could not set value '"cautious")' - The number of opening brackets "(" does not match the number of closing brackets ")".
The whole first part seems to magically disappear. Somehow.
Is there any way I can fix this? I'm using the online editor for gamebooks.
Pertex
22 Nov 2016, 07:44There seems to be a bug in the online editor. You can solve your problem by doing this:
x= GetInt(game, "cautious")
if (GetInt(game, "riskTaker") > x ) {
PrintCentered ("[Achievement Earned: You were a Risk Taker.]<br/>")
}
else if (GetInt(game, "riskTaker") < x) {
PrintCentered ("[Achievement Earned: You were Cautious.]<br/>")
}
else {
//some other message I haven't decided on yet
}
Ahh I found the problem. Quest doesn't like the space in
GetInt(game, "cautious")
Remove the space in front of "cautious" and it works

Shius
22 Nov 2016, 22:57@Pertwx, Thanks a lot!! I was able to get it working.