1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GML string_char_at question

Discussion in 'Programming' started by WinuX, Mar 30, 2017.

  1. WinuX

    WinuX Member

    Joined:
    Feb 17, 2017
    Posts:
    24
    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: Mar 30, 2017
  2. SnotWaffle Studios

    SnotWaffle Studios Member

    Joined:
    Jun 21, 2016
    Posts:
    291
    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);
    }
    
     
  3. WinuX

    WinuX Member

    Joined:
    Feb 17, 2017
    Posts:
    24
    Thank you very much, it works perfectly :D
     
    SnotWaffle Studios likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice