Quantcast
Channel: The VG Resource - All Forums
Viewing all articles
Browse latest Browse all 16315

Game Maker help

$
0
0
Hey everyone. I'm having trouble coding something, figured I could get some help

basically it's an app that tests if the number I inserted is even or odd. The coding in GML goes as follows:

Code:
var number = get_integer("Type a Number.",0);  
if( is_real(number)== true){
     if(number%2 ==0){
     show_message("The number "+string(number)+" is even.");
     }
      else if(number%2==1){
      show_message("The number "+string(number)+" is odd.");
      }
}
else{
show_message("Insert numbers only.");
}
The app gets the number and divides it by two. If there are no remainders, it is even; and if there is a remainder, it is odd.
the exact problem i'm having is that currently, I am able to type a word and since GML considers words as "0", the app gives out the even message when it is clearly not even (it's not even a number!!)

If there was a way to limit the input somehow I'd be very grateful.

Viewing all articles
Browse latest Browse all 16315

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>