Write files with Node-Webkit?

Get help using Construct 2

Post » Thu May 16, 2013 1:07 am

In r130, you can write text files with the Node-Webkit plugin. I tried doing that, but for some reason, its not working. Am I doing something wrong? Here's what I have:
B
29
S
7
G
3
Posts: 361
Reputation: 6,187

Post » Thu May 16, 2013 2:30 am

If you don't specify a folder, it will write it to the current directory, which IIRC is some random temporary folder. Try specifying a folder.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,518

Post » Thu May 16, 2013 2:50 am

@Ashley So, I write something like, "Desktop/Gamestuff/C2/win32"?
B
29
S
7
G
3
Posts: 361
Reputation: 6,187

Post » Thu May 16, 2013 1:54 pm

No, you should never hard code paths. Try something like NodeWebkit.UserFolder & "myfile.txt".
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,518

Post » Fri May 17, 2013 1:19 am

@Ashley Okay, I tried that, and it doesn't seem to work. Am I doing something wrong?
B
29
S
7
G
3
Posts: 361
Reputation: 6,187

Post » Fri May 17, 2013 1:41 pm

Post an example of your .capx if you need help.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,518

Post » Fri May 17, 2013 3:09 pm

Also, if you can, try to set a text to

NodeWebkit.UserFolder & "YOUSHOULDNTHAVEDONETHAT.txt"

in the same condition, to see the path he uses
https://www.scirra.com/forum/viewtopic.php?t=152506

And that is why you shall respect the bug reports guidelines, not only giving a capx is making the bug reproductible in one click in a situation they can work with (less time wasted trying to reproduce vague instructions) but also it helps filtering false positives.

Game design is all about decomposing the core of your game so it becomes simple instructions.
B
42
S
17
G
16
Posts: 2,090
Reputation: 15,347

Post » Sat May 18, 2013 12:43 am

@Ashley So, I found out where the files end up, using Aphrodite's method.

How do I make them go to the Desktop or change the path?
B
29
S
7
G
3
Posts: 361
Reputation: 6,187

Post » Sat May 18, 2013 12:54 am

@InvaderX :

If you used a form to ask for a folder path, use the expression NodeWebkit.ChosenPath & "YOUSHOULDNTHAVEDONETHAT.txt" just after

If you used a form to ask for a file saving, I guess you should use the expression NodeWebkit.ChosenPath just after

NodeWebkit.AppFolder & "YOUSHOULDNTHAVEDONETHAT.txt" should create the file in the same directory as the application

I didn't used it myself though

If you want to create a file from a game, it should be in the users documents (or a subfolder), or in the application folder (or subfolders), If the file can be created somewhere else, I think you may ask the user where, Games don't really need to create files outside these boundaries in generalAphrodite2013-05-18 00:57:22
https://www.scirra.com/forum/viewtopic.php?t=152506

And that is why you shall respect the bug reports guidelines, not only giving a capx is making the bug reproductible in one click in a situation they can work with (less time wasted trying to reproduce vague instructions) but also it helps filtering false positives.

Game design is all about decomposing the core of your game so it becomes simple instructions.
B
42
S
17
G
16
Posts: 2,090
Reputation: 15,347


Return to How do I....?

Who is online

Users browsing this forum: Pandadoor, Sotir31, Yahoo [Bot] and 31 guests