How do I Call a section, passage (text) from within a doc?

0 favourites
  • 10 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
  • What I mean is: After importing the text file into Construct 2 and calling it via Ajax, is there a way that I can select a specific part from within this document? Right now I only know how to call the document but I have to create a lot of different documents in order to achieve what I want. It would be nice if I had one long text document and only print on the screens the sections I choose.

    Help, please! Thanks!

  • You can parse the text in a multitude of ways. The right method to chose depending on your document structure.

    What does your document look like ?

  • You can parse the text in a multitude of ways. The right method to chose depending on your document structure.

    What does your document look like ?

    This is what I have:

    Ajax > Request TEXT.doc ("ReadData" >)

    OnTouch > SetText > Ajax.LastData

    So far so good. And the document looks like this:

    ----------------------------------------------------------------------------

    The quick brown fox jumps over the lazy dog.

    Pack my box with five dozen liquor jugs.

    Sphinx of black quartz, judge my vow.

    etc

    etc

    ---------------------------------------------------------------------------

    Imagine if I have to create 3 separate text documents in the example above, nonsense. Is there a way that I can just grab portions of text from one single document?

    Hope I was clear on this. thanks for taking the time.

  • You will need some tags or another mechanism to identify portion of the document.

    In your example, you could use the "tokenat" expression with "newline" as the delimiter. This way you could retrieve any desired line provided you know its rank in the sequence.

  • You will need some tags or another mechanism to identify portion of the document.

    In your example, you could use the "tokenat" expression with "newline" as the delimiter. This way you could retrieve any desired line provided you know its rank in the sequence.

    Thank you! I am fairly new to Construct 2 and game development. Can you tell me how I can do this?

    For example, if in a line of my text document the line starts like this: It is a nice day today, Should I add a tag before it?

    Like this: (TAG) It's a nice day today... Any special characters here?

    And in the Events Sheet, do I need a For loop? Could you just show me what Tokenat would look like on the Event Sheet?

    Thanks a lot!!!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • With a tag system, regular expressions will be your friend.

    Here's one way you could to it :

    https://dl.dropboxusercontent.com/u/700 ... ystem.capx

  • With a tag system, regular expressions will be your friend.

    Here's one way you could to it :

    https://dl.dropboxusercontent.com/u/700 ... ystem.capx

    Magistross, sorry it took me so long to reply. Had a busy day.

    Man, I have no words to thank you. Thanks for taking the time. I am still tweaking with it but I think I am going to be able to achieve this soon thanks to you.

    Thanks a bunch! Really!

  • I don't know if I can post this link here, if not I am sorry, but I came across this on Google and thought it was really helpful, too.

    https://github.com/jamesqquick/Construct-2/commit/aec86c1e3c127dd604638d4f487517bad09b8619

    Magistross thanks again, man. I learned a lot from your .capx file. Outstanding!!!!!!

  • No problem! Regular expressions may seem daunting at first, but when you understand its usefulness, you can't do without them!

  • No problem! Regular expressions may seem daunting at first, but when you understand its usefulness, you can't do without them!

    That's for sure! They are pretty daunting. Especially for me. I haven't had that much experience. But in the end I was able to use a lot of what you sent me and did some more research too. Ended up calling the lines from the document like this:

    trim(tokenat(AJAX.LastData,random(0,300),";"))

    I had no idea that all I had to do was to add a separator - (;) hope I used the right term - in my text document.

    I didn't know that the lines were counted by default, this line of code above for example, 0 is the first line of my document and 300 is the last, and I even randomized it. It works perfectly.

    I thought your example was neat. I will use in one of my projects for sure. But since I wanted to call the lines of text from a file because it had too much content, I came across another way. But definitely what you sent me opened up my mind to get where I got.

    So happy!

    Thanks!

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