newline in text object

0 favourites
  • 6 posts
From the Asset Store
OpenAI TTS
$10 USD
Text-to-Speech plugin.Allows your Construct 3 project to convert written text into spoken words
  • I insert a text object called Text2.

    Now in an action I set the text of this to an expression from a plugin object called texter. (texter.setit)

    now setit sets returns text like this:

         exps.getinfo = function (ret)     

         {

              currentinfo=currentinfo.replace("& Newline &",Newline);

               ret.set_string(currentinfo);          

         };

    now currentinfo is a global javascript variable and where i want newlines i insert the text "& Newline &", now when I return the string to the Text2 object i replace all "& Newline &" with Newline. But it doesnt work.

    So the question is can you insert some text code to let construct text object know that there should be a new line here like maybe " line 1 \n\r line 2" would show on screen like:

    line 1

    line 2

    Oh how complex...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Can you link your plugin?

  • why, its simple question.

    i.e when you set the text value for text object using a string returned from an expression how do you specify new lines?

  • In a plugin:

         exps.NewLine= function (ret, line1, line2)

         {

              ret.set_string(line1+"\n"+line2);

         };

    in c2: set text to myPlugin.NewLine("first line", "second line")

    ________

    In construct:

    set text to ("line1"&Newline&"line2")

    The word Newline isn't a text/string.

  • rafhelp - you seem to be confused, none of your code makes sense... newline is an expression in Construct 2's event system only and makes no sense at all in Javascript. Construct 2 replaces newline with '\n' by the time it reaches any plugin. So in your plugin you do not need to worry about line breaks at all. The user will simply use the newline expression where they want it in the event system, and your plugin will receive a string with \n in it.

    Edit: moving to SDK forum

  • Figured something out so I thought I would pass it on. The following code did not work for me.

    -----

    set text to ("line1"&Newline&"line2")

    -----

    Since it created Line1Line2, the textbox did not move it to different lines because it still thought it was the same word.

    This worked for me though:

    -----

    set text to ("line1 "&Newline&"line2")

    -----

    The space after line1 made the difference.

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