Cannot create or write file with Webkit

Get help using Construct 2

Post » Tue Feb 25, 2014 1:25 pm

Image

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.
B
3
Posts: 7
Reputation: 189

Post » Tue Feb 25, 2014 1:53 pm

You need to use NodeWebkit.AppFolder or NodeWebkit.UsetFolder.

Like this Write "hello" to file NodeWebkit.AppFolder&"myVehicle.txt"
B
34
S
9
G
3
Posts: 517
Reputation: 5,276

Post » Tue Feb 25, 2014 2:24 pm

That did nothing. As I said, both my AppFolder and UserFolder return nothing. In the debugger they are blank, no paths.
B
3
Posts: 7
Reputation: 189

Post » Tue Feb 25, 2014 4:11 pm

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

Image

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 :oops:
B
34
S
9
G
3
Posts: 517
Reputation: 5,276

Post » Wed Feb 26, 2014 3:58 pm

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
B
3
Posts: 7
Reputation: 189

Post » Wed Feb 26, 2014 8:53 pm

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.
B
34
S
9
G
3
Posts: 517
Reputation: 5,276

Post » Thu Feb 27, 2014 2:10 pm

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.
B
3
Posts: 7
Reputation: 189

Post » Thu Feb 27, 2014 6:23 pm

I assume that is the case.

https://www.scirra.com/store/construct-2
B
34
S
9
G
3
Posts: 517
Reputation: 5,276

Post » Wed Nov 19, 2014 3:06 pm

@Katala Is it possible to write, copy or move a file to UserFolder? I tried, but it failed. Thanks
B
61
S
14
G
5
Posts: 102
Reputation: 7,724

Post » Wed Nov 19, 2014 4:23 pm

@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!
B
34
S
9
G
3
Posts: 517
Reputation: 5,276

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 5 guests