• 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 line break problem

OverLogic

Member
Code:
if string_length(keyboard_string)<limit
{
    if string_length(input)==16
    {
        string_insert(input,"#",last_letter);
    }
    input = keyboard_string;
    input = string_letters(input);
    last_letter=input;
}
I am trying add a line break after i reach 16 letters so the 17 letter will be in the a line below.
 
D

DaMuffin

Guest
I've never used "string_insert" before so I'm not too sure, but is "last_letter" a parameter or local variable?
Anyway, maybe something like this will work

///CREATE EVENT
Code:
number_of_lines = 1; //If you know how many lines there will be, then change this to that amount.
break_lines = "true";//Determines whether to even run the code that will break the string.
///ELSEWHERE
Code:
if break_lines=="true"
{
  if string_length(keyboard_string) < limit
  {
    for(var char_position = 0; char_position <= string_length(input); char_position++)
    {
      if char_position = 16*number_of_lines
      {
        string_insert(input,"#",char_position);
        number_of_lines++;
      }
      if char_position = string_length(input)
      {
        break_lines = "false";
      }
    }
  }
}
EDIT:
I am curious about the line
Code:
if string_length(keyboard_string) < limit
because if the string is longer than the limit, the the string won't be broken.
 
Top