• 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!

Windows Need help making a string

I

itarkytec

Guest
Hola comunidad, estoy necesitando un poco de ayuda, agradecería que las respuestas a este post estén preferiblemente en español, aunque si es de ayuda no me molestaría en recibirla de todas maneras.

Contexto: estoy intentando hacer un cuadro de texto que solo acepte números como entrada, incluyendo los signos de los números (+ y -), mi problema es la las funciones de gamemaker para limpiar strings de letras y solo dejar números reales, me quita también los signos.
GML:
string_digits();
y no encuentro ninguna función para mi objetivo, y tampoco conozco suficiente el programa como para crearla yo mismo... ¿Tienen alguna idea de como solucionarlo?...

estoy ocupado la ultima versión de gamemaker studio 2, publicada hasta la fecha 18/01/2021. agradezco cualquier critica a la traducción que estoy por hacer, puede que tenga muchos errores, así que pido el máximo respeto a cualquier comentario.

Gracias. :3

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


Hello community, I am needing a little help, I would appreciate if the answers to this post are preferably in Spanish, although if it is helpful I would not bother to receive it anyway.

Context: I am trying to make a textbox that only accepts numbers as input, including the signs of the numbers (+ and -), my problem is the gamemaker functions to clean strings of letters and only leave real numbers, it also removes me the signs.
GML:
string_digits();
and I can't find any function for my purpose, and I don't know enough about the program to create it myself ... Do you have any idea how to fix it? ...



I'm busy with the latest version of gamemaker studio 2, released until 01/18/2021
 

obscene

Member
Each time an input is received from the user, check that single character.

If (char!="+" && char!="-" && char!="x" etc...) char=string_digits(char);
your_string=string_insert(char, your_string, string_length(your_string)+1);

Not tested, but something like that should do it.
 
use unicode for your checks.
for 0-9: Unicode range 48 to 57 (included)
plus sign: Unicode 43
minus sign: Unicode 45

If it's not one of those, it's not a number or a +/- sign
 
Top