How to read text files outside from Construct in an specific line?

  • Hey bois, i'm trying to make an riddle game, and the first challenge is for the player to realize that, he will have to go inside the game folder, and open a file called "Layout.txt", which contain the following letters:

    OnStartup:LoadLayout("Blank");

    And then, every time he starts the game, he reads the part ("Blank") soon, Blank, will go to a variable in which it will be compared, and if he agrees with the comparison, he will move to another layout, soon at first. My problem is, how can i do to read a file outside of construct 2 (I don't want any suggestions to be told to add the file to C2) on a specific line? (I've tried using ajax, NWjs, however, I don't know how to read a file from outside C2, and this will be necessary because the player itself will have to change it, and if I upload it to C2, the player will not have access to the file.)

    Objective: To be able to read the specific part of the text file outside Construct 2 (Like in game's directory , in which if the player changes to the name of some layout (which will be given when the player finishes a puzzle within the game)), in which that he will do to progress, he changes the layout for the written agreement where the ("Blank") is, (Blank is the initial layout, so the player will have to change the name to enter the next one.) and then, continue progressing in the game, and changing layouts through of that system.

    Summarized: Read ("Blank"), in an text file that has to be outside of the Construct (Like in the game's folder), using ajax, NWjs or any other plugin, in which you can read text files outside the Construct.

    Please help, i'm trying to solve this for more than an day, i know this is such an specific question, but, any help will be so grateful!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can read and write external files using the NWjs object.

    Check the NWjs object documentation and this example capx.

    Hope this helps...

    Cheers!

  • You can read and write external files using the NWjs object.

    Check the NWjs object documentation and this example capx.

    Hope this helps...

    Cheers!

    Thanks man, that worked perfectly! But, can you tell me a way to select in the specific line that i want in the txt file? Like: OnStartup:LoadLayout("Blank"), just to select the 21 caracter: ( and all the text next: "Blank") , because i need to save then to an variable.

  • Hey!

    Sorry for the delay. Been away a while.

    You'd have to use the string manipulation expressions. The "Text" section of the System Expressions page in the manual would be specially useful for you. Take a look at it here.

    If you say exactly how you save and what I may be able to help you with more specific detail.

    Feel free to contact me directly through pvt or tag me in your message if I don't answer for a long time. ;)

    Cheers!

  • Hey!

    Sorry for the delay. Been away a while.

    You'd have to use the string manipulation expressions. The "Text" section of the System Expressions page in the manual would be specially useful for you. Take a look at it here.

    If you say exactly how you save and what I may be able to help you with more specific detail.

    Feel free to contact me directly through pvt or tag me in your message if I don't answer for a long time. ;)

    Cheers!

    I just solved already, but, thanks anyway, you helped a lot!

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