0 Favourites

Cannot create or write file with Webkit

  • So I'm trying to write save info to a file on my desktop, but the file does not get created. I try creating the file on the desktop in hopes that it would at least write to it, but no luck there. Currently I'm just trying to get it to write anything, thus "hello." I checked the debugger and the root is properly defined. One odd thing is Webkit.appfolder and userfolder are blank and I can't use those, maybe a symptom of the problem? At any rate I'm running it in preview mode so its not necessary currently.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • You need to use NodeWebkit.AppFolder or NodeWebkit.UsetFolder.

    Like this Write "hello" to file NodeWebkit.AppFolder&"myVehicle.txt"

  • That did nothing. As I said, both my AppFolder and UserFolder return nothing. In the debugger they are blank, no paths.

  • Sorry I should get eyes. And forgot you should use WebStorage. Something like this.

    Also maybe it's just me but I just noticed you have your files on exporters/html5/node-webkit/win32

    I used to export every time I preview something that needs loading from file

  • I couldn't figure out where you were getting the Button | function = "save" condition. Though I did create a similar test using your suggested actions. I don't care so much about loading right now cause I can't write. Is there a disadvantage to spelling out the entire path I want the file to go instead of using AppFolder? Remember I'm just trying to get the program to write a file. Which isn't happening no matter what I do.

    So I created the simplest of programs. All it has is a button and a text box. Click the button and it prints the appfolder location to the text box.

    In Preview mode: nothing shows up

    In Exported mode: nothing shows up

    In Exported and Uploaded to Web mode: nothing shows up

  • Those functions are just button Instance variables. Here is CAPX for just saving.

    https://dl.dropboxusercontent.com/u/104893773/C2%20examples/Webkit%20simple%20save.capx

    For finished game it really is not good idea to hardcode paths.

    Also did you read this https://www.scirra.com/manual/162/node-webkit

    If for some reason you don't get it to work with the help of the manual please post the CAPX.

  • Sigh...

    Your file worked perfectly and is exactly what I need. So I tried adding it to my project. Now it doesn't work. Then I tried making a new project that copied yours exactly, and it also does not work. So I think I now understand the true nature of my problem. You were able to export your project as a Node-Webkit. Whereas I am stuck to HTML5. Or it could simply be that you have a license and I don't. What a shame.

  • Katala Is it possible to write, copy or move a file to UserFolder? I tried, but it failed. Thanks

  • nothaseo

    Yes. I would probably use.

    Nodewebkit Path doesn't exist => Create Folder NodeWebkit.UserFolder&"Documents/1Ultimate Game"

    Then just write file.

    Path = NodeWebkit.UserFolder&"Documents/1Ultimate Game/Config"

    Content = Whatever but, note that for some reason if you just try to save plain text from text plugin or textbox I get some weird results. So it would be good to save as JSON.

    Haven't tested all the functionality but, there should't be much else to it.

    As you see from the list on functions that it indeed can move files etc. and even detect dropped files.

    Use debugger to check what NW is actually doing if you run into problems.

    Edit:Make sure you preview as Node-Webkit!

  • Katala

    Thanks for the help. And is it okay to "/" or "\" as we prefer?

  • [quote:3bfm4n8l]Thanks for the help. And is it okay to "/" or "\" as we prefer?

    As far as I know both work fine.

  • Thanks Katala

    Now Im able to create, copy, and write a file

    I get a new problem when I want to copy a folder with all its contents. The folder and the contents are never copied to the specified location. Is it possible to do it?

    it will be time consuming to create a folder n copy the files one by one.

    Thanks

  • nothaseo

    -List files from the folder.

    -Run loop list count times

    -Move "PATH/"&NodeWebkit.ListAt(loopindex)

    -To "PATH/"&NodeWebkit.ListAt(loopindex)

  • nothaseo

    -List files from the folder.

    -Run loop list count times

    -Move "PATH/"&NodeWebkit.ListAt(loopindex)

    -To "PATH/"&NodeWebkit.ListAt(loopindex)

    Thanks again Katala

    But can you explain more about "Run loop list coun times" I dont really get it.

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