Using text out of a .txt file

0 favourites
  • 6 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • Hello everyone

    I don't know if this is stupid question but I need to use textlines out of a .txt file in C3.

    I know that I can use AJAX object, but I have a lot of files that I am requesting.

    If the other files are completed, I upload the data into arrays, but where can I put the data of a .txt file?

    If have so many rajax requests so I can't just use AJAX.Last data... Is there another way to select just this request?

    An other question: Can I select some lines out of .txt file using tokenat?

    Thank you in advance!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can always use AJAX.LastData no matter how many requests you are making, as long as you are identifying each one with a tag. If you use the AJAX On Completed Trigger with the proper tag, AJAX.LastData within that event will have the correct data requested.

    You can save the entire lastdata/text contents into any variable, and how you want to break it up with tokenat after that is up to you.

  • Thanks for your reply and tip!

    1 more question:

    I have this situation right now:

    a button triggers a text object to show some text out of the .txt file.

    Since 'on completed ajax request' can not be combined with the button trigger, what should I do?

    Can I use just the tag everywhere?

    Thank you!

  • I found a way to do it:

    compare two values:

    ajaxTag = "tag" -> action: ajax.Lastdata

    Thanks for your help!

  • Normally On AJAX completed, you store the lastdata into a variable. If your tag is unique to that button's data, just display that variable on button press.

    If you have multiple requests that may overwrite each other (same tag), you can push them into an array when completed instead, so that they are all stored in the order they are completed. Then when you click the button, you can read the last completed data from the last index of the array, or have some other way to choose the index to read from.

  • Thanks for your inspiring advice!

    I didn't think that way yet!

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