• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Is real not working

The following code does not work.

if is_real(keyboard_lastchar) then show_message("x");

I don't see the issue. I'm going to have to say does it = 0, 1 ,2 or 3 etc?
 

Nidoking

Member
Sorry, early in the morning and I got confused. Is it just not showing the message you wanted? What IS the last character pressed?

A bit of research shows that keyboard_lastchar is a string variable and will therefore never be a real variable. Did you perhaps intend to check whether the last character is a digit? Because I think you'd want something like string_digits and check to see whether it's empty.
 
Last edited:

Sabnock

Member
you are asking if a key press is a real number.

what is it you are trying to achieve?

if (keyboard_lastkey == ord("X")) show_message(keyboard_lastchar);
 
Well I am adding it to a variable for a textbox. However, even if I do

test_string += keyboard_lastchar. Is this a number or a string.

I just want to know if the last key was a number a letter or other basically.

Edit: I have quite a comprehensive text box that is all but done. I am now writing a script to deal with formatting. For example time, date, US and UK date, currency, weights, etc

This will have a list of acceptable inputs. So UK date would be Number, number, forward slash, number, number, forward slash, number, number, number, number, number.

Before each character is committed to the textbox it will be checked to see if it meets these conditions. Hence I just want to grab the last key and check if it is compliant.

This was I can easily add a new format type, wack him in the constants list, and bingo bongo.

I can check all the numbers and letters manually which is bad. The other way I could do it would be to check the UTF range but I want to do it the original way I suggested as its cleaner. Also I have had a number of issues with data types in GMS (Checking for boolean is one) and want to figure this out.
 
Last edited:
I figured out what was needed it was string_digits(keyboad_lastchar);

Thanks.

Edit: Changed my mind using ord it does seem cleaner after all.
 
Last edited:
Top