1. Hey! Guest! The 34th GMC Jam will take place between August 22nd, 12:00 UTC (Thursday noon) and August 26th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

GM:S 1.4 make linebreaks go up instead of down?

Discussion in 'Programming' started by Dengar, Jun 24, 2016.

  1. Dengar

    Dengar Member

    Joined:
    Jun 21, 2016
    Posts:
    285
    im using strings like this "dengar#bob#sam#"
    and it looks like this when drawn:
    dengar
    bob
    sam

    what I want is it to reverse it and display:
    sam
    bob
    dengar

    so the line breaks "#" put the new line above the previous line instead of below it.
     
  2. Snail Man

    Snail Man Member

    Joined:
    Jun 20, 2016
    Posts:
    282
    There's no way to do this. I would either use a script to flip a string by line breaks (I would write it if I weren't on mobile), or just write all the names in reverse manually.
     
  3. stainedofmind

    stainedofmind Member

    Joined:
    Jun 20, 2016
    Posts:
    700
    Or, you can put each line into a data structure and draw them in reverse order. It all depends on exactly what you're trying to do. Why do you want to draw a string in reverse line break order? Is it for a list you want to draw where the newest entries are on top and older ones get pushed down?
     
  4. gnysek

    gnysek Member

    Joined:
    Jun 20, 2016
    Posts:
    1,305
    "sam#bob#dengar" is a solution for you :)
     
  5. ThunkGames

    ThunkGames Guest

    Use this script here: http://www.gmlscripts.com/script/explode

    And then:
    Code:
    var lines = string_explode("#", str); //str is your text
    var cnt = string_count("#", str);
    var newStr = "";
    for (var i = 0; i < cnt; i++) {
    newStr += lines[cnt - (i + 1)] + "#";
    }
    newStr = string_delete(newStr, string_length(newStr), 1); //there you have it!
    lines = noone;
    Typed on mobile please excuse typos.
    -David
     
  6. Dengar

    Dengar Member

    Joined:
    Jun 21, 2016
    Posts:
    285
    its for a chat system and im trying to keep things simple. that's why id like to use gm's linebreak symbol instead of drawing each line seperatly.
    but I want it to look like a chat, meaning newlines are added to the bottom.

    I think what u wrote is essentialy what I was thinking. manualy re-arranging the string and then printing it.
     
  7. stainedofmind

    stainedofmind Member

    Joined:
    Jun 20, 2016
    Posts:
    700
    If that's the case, instead of adding new lines like this:

    Code:
    chat_text += "#" + new_line;
    
    ... Add them like this:

    Code:
    chat_text = new_line + "#" + chat_text;
    
    ... Then you don't have to worry about any fancy features and can just use the draw_text function.
     
    ParodyKnaveBob 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