Reading lines from a text-file.

This forum is currently in read-only mode.
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 couldn't figure out how to put the title, and I guess I can't explain it too well, but here goes.

    Is there a way to read specific lines from a text file?

    If I had a file called positive.txt that would be like this:

    cool guy

    smart

    pretty

    nice

    and I want a text to change into one of those at random, how would I do it? Is it even possible?

    Oh, and I'd love to have it so that if you add a line, it can automatically tell that there is a new line, so you can add stuff into the file without changing the application in Construct. So it kind of counts the lines or something.

    There, I hope you understood.

  • The only way I've managed to do something like this is by loading the text file using the list object. This will load the text file, giving each line it's own seperate line in the list object, allowing you to change whichever one you want.

  • The only way I've managed to do something like this is by loading the text file using the list object. This will load the text file, giving each line it's own seperate line in the list object, allowing you to change whichever one you want.

    For me the list-object just remains empty, no text, but the vertical scroll bar goes smaller if I make it add the file when I click and click a few times and it says the correct amount of lines.

  • For me the list-object just remains empty, no text, but the vertical scroll bar goes smaller if I make it add the file when I click and click a few times and it says the correct amount of lines.

    That's strange. I tested it just now, and it loads just fine. Are you just using the "Load from file" action?

  • Nevermind, got it to work, and it works flawlessly!

  • Glad I could help.

  • You could also use the Text Manipulator which can read line by line.

  • You could also use the Text Manipulator which can read line by line.

    I couldn't figure out how to make it read any other line than the last line.

    But list-objects saved my day! It works like a charm now!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There was a bug in this, but it's fixed now.

    In the next build, you can use 'Read file line by line' and then in a new event the 'On line read' will trigger for every line.

  • Hi i need to do this exact thing too but i don't quite know what you mean by using the list object. Is this a feature only available in the none free version?

    Nor do i understand where to find or even write Read file line by line

  • FookinNora Luckily this is the Construct Classic forum, so it's completely free/open source. Are you trying to do this in Construct 2?

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