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
30
S
8
G
3
Posts: 366
Reputation: 6,302

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
398
S
236
G
88
Posts: 24,428
Reputation: 194,625

Post » Thu May 16, 2013 2:50 am

@Ashley So, I write something like, "Desktop/Gamestuff/C2/win32"?
B
30
S
8
G
3
Posts: 366
Reputation: 6,302

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
398
S
236
G
88
Posts: 24,428
Reputation: 194,625

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
30
S
8
G
3
Posts: 366
Reputation: 6,302

Post » Fri May 17, 2013 1:41 pm

Post an example of your .capx if you need help.
Scirra Founder
B
398
S
236
G
88
Posts: 24,428
Reputation: 194,625

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
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

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
30
S
8
G
3
Posts: 366
Reputation: 6,302

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
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 37 guests