This is driving me crazy!

Discussion and feedback on Construct 2

Post » Sun Aug 16, 2015 7:46 am

I'm so close to archieving my goal for a new feature in my game, but i need one last step!

Baiscally, my game takes a canvas snapshot (in NW.js), and automatically saves it on the computer in png.

I use a custom js to do that:
"var fs = require('fs');fs['writeFileSync']('" &replace(NodeWebkit.UserFolder & "screenshot" & ".png","\","\\")& "','" &CanvasSnapshot& "'.split(',')[1], {'encoding': 'base64'});"

I just want it to save on the user Desktop, and possibly on a custom folder created there. I know the part i need to focus on is replace(NodeWebkit.UserFolder, but i really have no clue of how to point it to the desktop, and then a custom new folder :oops:

Anyone can help? Plz :roll:
B
65
S
22
G
4
Posts: 358
Reputation: 6,555

Post » Sun Aug 16, 2015 10:10 am

use action NW.JS create folder NodeWebkit.UserFolder&"/Desktop"&"/"&YourFolder (edit1: If "YourFolder" is a global var text, else you must use NW.JS create folder NodeWebkit.UserFolder&"/Desktop"&"/YourFolder")

Perhaps I'm off topic but:
1/why you don't let Steam manage screenshot?
2/ As Gamer, I dislike that a game creates some folders or files on my Desktop

Edit2: Do you want a capx ?
Image Image
B
22
S
13
G
135
Posts: 871
Reputation: 70,320

Post » Sun Aug 16, 2015 10:47 am

Oh, well i have a good reason to do that: in my game, the world evolves based on ecological principles, i've created a system that takes a screenshot of the island every ingame day, automatically. After ingame years, you get hundred of screenshots and you can bundle them and create a sort of "history show" of it's evolution. It's an optional feature disabled by default.

Thanks for the info, i'll try it as i get home and report back!
B
65
S
22
G
4
Posts: 358
Reputation: 6,555

Post » Sun Aug 16, 2015 11:01 am

I suggest you save them in folder "User/Documents/DinoSystem/ProfilName/History/file_xxxx.jpg"
Let us know if it works as you want
Image Image
B
22
S
13
G
135
Posts: 871
Reputation: 70,320

Post » Sun Aug 16, 2015 2:06 pm

Yep, Documents is way more professional!

PS: it works like a charm, but i had to find out that in the js code the path has to be reported with "\folder\"!

Thanks a lot, mission accomplished!
B
65
S
22
G
4
Posts: 358
Reputation: 6,555

Post » Sun Aug 16, 2015 2:17 pm

you could try to save your files in game folder (with js code) then move them in the folder you want with NW.JS
Image Image
B
22
S
13
G
135
Posts: 871
Reputation: 70,320

Post » Sun Aug 16, 2015 2:27 pm

It works as it is now, here's the js:

"var fs = require('fs');fs['writeFileSync']('" &replace(NodeWebkit.UserFolder&"\Documents\"&"\DinoSystem\"&"\History\" & "DScreen" & SnapN & ".jpg","\","\\")& "','" &CanvasSnapshot& "'.split(',')[1], {'encoding': 'base64'});"

the SnapN is just a variable to number the screens


Is there any advantage in changing to the way you suggested?

PS: is there a way to tell the game to delete a folder? Looks like i can delete only a single file, but i want to delete all files in the given folder or the whole folder. Just an optional thing though.
B
65
S
22
G
4
Posts: 358
Reputation: 6,555

Post » Sun Aug 16, 2015 2:39 pm

you can call cmd prompt with NW.JS to delete your folder but it's not a way too professionnal
Image Image
B
22
S
13
G
135
Posts: 871
Reputation: 70,320

Post » Sun Aug 16, 2015 2:52 pm

Yea, it's not very professional indeed xD
B
65
S
22
G
4
Posts: 358
Reputation: 6,555

Post » Sun Aug 16, 2015 2:56 pm

But it works... I admit I don't try another way for the moment
Image Image
B
22
S
13
G
135
Posts: 871
Reputation: 70,320

Next

Return to Construct 2 General

Who is online

Users browsing this forum: MadSpy and 5 guests