Users browsing this thread: 1 Guest(s)
Game Maker help
#1
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.
Spriter Gors】【Bandcamp】【Twitter】【YouTube】【Tumblr】【Portifolio
If you like my C+C, please rate me up. It helps me know I'm helping!
[Image: deT1vCJ.png]
Reply
Thanked by:


Messages In This Thread
Game Maker help - by Gors - 03-30-2016, 02:09 PM
RE: Game Maker help - by Rhyme - 03-30-2016, 02:18 PM

Forum Jump: