Number Variables
cdutton184
09 Mar 2012, 20:13I know I'm being dumb but I can't seem to compare number variables without getting errors.
For example, I put a variable game.randnum from 1000 to 9999 in the Game Attribute and make it a random number. I presume to create another variable game.answer in the Game attributes as well.
Let's say a combination lock needs a 4 number code. When the command is ENTER CODE and I set the variable game.answer as an user input (GetInput). So on RUN, Looking at the Debugger when a number is inputted in the Game attributes will be two numbers for randnum (as expected) and answer (the number inputted) - so far so good.
Now this is the point I don't understand. I've tried an IF command but not sure what the <expression> is.
I've tried game.answer = game.randnum but get an INT32 and STRING error.
Even game.randnum - game.answer = null doesn't work.
There needs to be a guide in the Wiki Quest to explain fully how to create, compare and mathematically change number variables because I'm lost.
It was so much easier with Quest 4!
For example, I put a variable game.randnum from 1000 to 9999 in the Game Attribute and make it a random number. I presume to create another variable game.answer in the Game attributes as well.
Let's say a combination lock needs a 4 number code. When the command is ENTER CODE and I set the variable game.answer as an user input (GetInput). So on RUN, Looking at the Debugger when a number is inputted in the Game attributes will be two numbers for randnum (as expected) and answer (the number inputted) - so far so good.
Now this is the point I don't understand. I've tried an IF command but not sure what the <expression> is.
I've tried game.answer = game.randnum but get an INT32 and STRING error.
Even game.randnum - game.answer = null doesn't work.
There needs to be a guide in the Wiki Quest to explain fully how to create, compare and mathematically change number variables because I'm lost.
It was so much easier with Quest 4!
Garan
09 Mar 2012, 20:26I'm very new to using Quest, but could it be that the input is being handle as a string, and you'd need to change it to an integer to be able to use it in that context?

Pertex
09 Mar 2012, 21:43You are right, Garan.
You can cast it like this:
You can cast it like this:
if (isNumeric(game.answer)) {
game.answerint =ToInt (game.answer)
} else {
msg("wrong input")
}