This is driving me crazy!

0 favourites
From the Asset Store
Make your own Isometric RPG, Visual Novels, or Story Driven Puzzle game!
  • 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

    Anyone can help? Plz

  • 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 ?

  • 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!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I suggest you save them in folder "User/Documents/DinoSystem/ProfilName/History/file_xxxx.jpg"

    Let us know if it works as you want

  • 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!

  • you could try to save your files in game folder (with js code) then move them in the folder you want with NW.JS

  • 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.

  • you can call cmd prompt with NW.JS to delete your folder but it's not a way too professionnal

  • Yea, it's not very professional indeed xD

  • But it works... I admit I don't try another way for the moment

  • Yep it works! Thank you

  • Which command did you used?

  • I moved the bat file in the Dinosystem directory, and it has this:

    rmdir /Q /S History

    Edit: changed with DEL /Q /S "%USERPROFILE%\Documents\DinoSystem\History\*.*"

    works better and doesnt need to stay in the same folder. But the confirmation pop-up problem is still there

  • Unfortunately , I haven't other way for you for now...

  • Ok, i managed to make it work silently, dunno how (as always), hate when things work and i dont know why, i prefer they dont

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