How do I Create a line break on json read file?

0 favourites
  • 8 posts
From the Asset Store
Convert multiple Excel files into JSON files and import them into construct3.
  • In my game i have a json file that im using for multilanguage interface, and the dialogues.

    So i load the json into a array and put something like this "set text to language.At(29,language)", the first language is the array, and the second one is teh global language variable that points to the row with the selected language.

    The problem is that i have some text for the story that neds line breaks and some other stuff.

    So what is the best way to do that?

  • The easiest method I know is to replace line breaks with some tag or a character, for example:

    The quick brown fox^jumps over the lazy dog

    When you are loading strings into the array, or when you need to display the text on the screen, replace "^" with newline:

    Dialog Set Text to replace(RextFromArray, "^", newline)

  • Thanks.

    Another question i have special characters on my language json file things like "Selecione Módulo".

    Buth when i load them they do not show. anyone know why?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Maybe you are using a font or spritefont that doesn't support these characters. Check if these characters are displayed correctly in Debug View.

  • they do support but when i load from the json it does not come

  • Are you loading this text from a file included in the project?

    It works for me, here is the built-in JSON template:

    .

  • As i mentioned i load the json into a array and when loading from the array it does not load.

    also it is possible to change the font on a text object based on a variable?

    What i mean is that i imported 3 fonts into my project, and i need to change the font on the tex object based on a blobal variable.

  • As i mentioned i load the json into a array and when loading from the array it does not load.

    It should still work. You need to post your project file.

    also it is possible to change the font on a text object based on a variable?

    Yes, use "Set font face" action.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)