soviet shrek's Forum Posts

  • 6 posts
  • Awesome! Sorry for the delay. Everything worked as planned!

    Thanks for the help

  • Thanks for the ip dop2000 ! The folder wasn't my project one but in program files. Is there anyway to modify that?

  • soviet shrek Try this:

    NWjs.ReadFile(NWjs.AppFolder & "test.json")

    In my case NWjs.AppFolder="C:\Program Files\NWjsForC2\win32\", so when I put test.json into that folder, it works.

    Do you have to manually set NWjs.AppFolder to a folder or the program does it but itself?

    The NWjs.ReadFile(NWjs.AppFolder & "test.json") doesn't work but NWjs.ReadFile("hard-coded path" & "test.json") did worked. I also check for writing/reading permission but nothing to worry there. In the meantime of finding out a work-around, I've replaced the .appfolder expression by a global string variable that indicate my folder in case I change my project location. It works but I still have to declare a hard-coded path to my variable.

  • Set s to NWJS.readFile("d:\temp\file.json")

    Or you can even load it directly into the array:

    Array load from JSON NWJS.readFile("d:\temp\file.json")

    Using a newly created folder in d:\temp\ it worked! Thanks a lot!

    Although, using either NWJS.userfolder or NWJS.appfolder doesn't seems to work. Is there anyway

    without using hard-coded path? Like a subfolder from where the project is located instead?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi, do you want to read a JSON file from the disk?

    I am doing it without problems with NWJS, I simply use NWJS.readFile and get the JSON information from the file on disk.

    Yes I want to read the .json file from the disk and load its data into an array. The .json file is a array that was exported earlier.

    I'm not sure on where to use the expression. I've tried the NWJS.readFile expression with NWJS.appfolder into "load array" but without that doesn't seems to do anything.

  • Hi!

    I'm having some trouble with NW.js functionnality.

    Basically, while the game is running, I want to import on demand a .json file (using a different string as a parameter to indicate the name of the file requested) and load it into a array.

    I've tested successfully the "open dialog" method (in which the user select which file he wants to import) but I want the same process to happen without having the user to select it (so no dialog box). I'm not sure I'm clear here but I am trying my best lol.

    I also know the AJAX function can import file but I feel it is pretty restricted because you have to manually select which file you want to import.

    tl;dr

    want to know if possible (and how in that case) if the game can import .json files ingame without user assistance.

    Thanks!

  • 6 posts