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

GML string_char_at question

W

WinuX

Guest
Hello everyone

Is it possible to read the whole number not just the first number that comes after the "\"

upload_2017-3-30_18-26-53.png

Because I want to have more than 10 modifiers and i don't want to make it into a string so i can use letters as well is there any possible solution?

EDIT: btw. "i" is the current string position in the typewriter textbox
 
Last edited by a moderator:
Loop through reading chars until you're at the end of the string or you reach a pre-defined terminating character.
For example:
Code:
var len = string_length(global.txt[global.txt_current]);
var z = i;
var tmp = "";
if(string_char_at(global.txt[global.txt_current],z]) == "\")
{
     while(z<len){
          tmp+=string_char_at(global.txt[global.txt_current],z+1);
          z+=1;
     }
     modifier=real(tmp);
}
 
W

WinuX

Guest
Loop through reading chars until you're at the end of the string or you reach a pre-defined terminating character.
For example:
Code:
var len = string_length(global.txt[global.txt_current]);
var z = i;
var tmp = "";
if(string_char_at(global.txt[global.txt_current],z]) == "\")
{
     while(z<len){
          tmp+=string_char_at(global.txt[global.txt_current],z+1);
          z+=1;
     }
     modifier=real(tmp);
}
Thank you very much, it works perfectly :D
 
Top