dialgpalkia
Member
Hey all,
I'm trying to add a textbox into my game that takes only floating numbers, but I'm struggling to get it to work. here's my code:
But it's throwing up an error whenever keyboard_lastchar = "" (which is the default). When I mess with the code, I can't type anything at all into the textbox. I've tried
But that hasn't worked either - I can't put any numbers in the box.
Previously I was using:
Which was working, but I need to use decimals too. Any ideas? I've scoured the web and haven't found anything that's really helped.
I'm trying to add a textbox into my game that takes only floating numbers, but I'm struggling to get it to work. here's my code:
GML:
if(string_length(keyboard_string) < maxNumberOfCharacters){
var is_realnumber = is_real((keyboard_lastchar));
if(string_length(is_realnumber)){
message = keyboard_string; //Store what is typed in variable message
}
} else {
keyboard_string = message;
}
GML:
var is_realnumber = is_real((keyboard_lastchar)) || keyboard_lastchar == "";
Previously I was using:
GML:
if(string_length(keyboard_string) < limit){
var is_number = string_digits(keyboard_lastchar);
if(string_length(is_number)){
message = keyboard_string; //Store what is typed in variable message
//keyboard_lastchar = "";
}
} else {
keyboard_string = message;
}
Which was working, but I need to use decimals too. Any ideas? I've scoured the web and haven't found anything that's really helped.