Mark91

Veteran
Veteran
Joined
May 19, 2017
Messages
155
Reaction score
18
First Language
Italian
Primarily Uses
RMMV
Hi, super forum~
I want to use an autosave plugin in my game, and this morning I woke up with this idea: in addition to saving by itself, can the game create a backup of the file in a specific directory (a USB, for example) automatically?
I was thinking of copying the save file from one place to another using javascript right after an autosave, but I don't know how to do it... is there a way?
Greetings
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,843
Reaction score
1,666
First Language
English
Primarily Uses
RMMV
If you simply Google "JavaScript copy file" you'll find the code syntax for it. But I would advise against it on the grounds that it's rather complicated and unnecessary.

Complicated: Drive letters for USB devices can change depending on the order that things are plugged into the computer. So the only way to make sure you're backing up to the same place every time is to have the user enter information every time they play, which would be annoying for little to no benefit.

Unnecessary: What game have you ever played that does anything like this? Do you really believe that somehow a player is going to intentionally navigate to the game directory and somehow accidentally delete their save folder? And then somehow be unable to restore it from their recycling bin?
 

Mark91

Veteran
Veteran
Joined
May 19, 2017
Messages
155
Reaction score
18
First Language
Italian
Primarily Uses
RMMV
If you are referring to this:

//copyfile.js const fs = require('fs'); // destination will be created or overwritten by default. fs.copyFile('C:\folderA\myfile.txt', 'C:\folderB\myfile.txt', (err) => { if (err) throw err; console.log('File was copied to destination'); });

I tryed it (replicating file and folders names) but it didn't work for me.
I guess I should adapt it to rpgmv somehow, but I never studied javascript so I asked here.

I'm just afraid of hdd/ssd problems (mine is really old) and I wanted implement this possibility; surely I won't force anyone to keep a usb inserted in order to play :LZSlol:
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,843
Reaction score
1,666
First Language
English
Primarily Uses
RMMV
If you're concerned about your own drives:
1) I'd suggest you regularly back up your entire project, which would include the save folder. You can use a USB drive, second hard drive, cloud storage, etc. There seems to be little reason to copy your save every time it autosaves unless you have a reason to believe your drive is going to fail in the middle of your play session (in which case you probably should be keeping the computer turned off until you can install a replacement).

2) You can automate that backing up of your project via Windows much more easily than coding it into your game project when you're the only person likely to benefit from it.
 

Mark91

Veteran
Veteran
Joined
May 19, 2017
Messages
155
Reaction score
18
First Language
Italian
Primarily Uses
RMMV
I perfectly understand your point of view and I didn't know about your 2) point; surely I'll use it to regularly back-up my games folder.

Still, since I like to discover new possibilities even if I'm a total javascript noob, and since I'm still interested in copy&paste files through javascript, I'll keep this thread open for a while.
If someone is interested in the same thing or just know how to do it, and wanna share it, I'm here~
 

GregorDuckman

Villager
Member
Joined
Oct 14, 2021
Messages
21
Reaction score
16
First Language
English
Primarily Uses
RMMZ
Hi, super forum~
I want to use an autosave plugin in my game, and this morning I woke up with this idea: in addition to saving by itself, can the game create a backup of the file in a specific directory (a USB, for example) automatically?
I was thinking of copying the save file from one place to another using javascript right after an autosave, but I don't know how to do it... is there a way?
Greetings
This type of thing is generally considered a no-no in multiplatform engines, because the exact method would be platform specific as well as context specific (USB drive in what USB port, etc). The example in this thread presupposes Windows because it uses "C:/" directory structure. This would probably crash any mobile or web deployments.

Personally, I have my RMMZ projects saved in my OneDrive, which offers a very basic level of backup. If I wanted to save extra copies / autosaves, I'd look at how RMMZ handles saves, and at every line where it writes the file to the save location, I'd have it write an extra file with a unique name every time (the exact time and date for example). Combine this with OneDrive / Google Drive / Windows backups, and you can keep a very long history of save files.
 

Latest Threads

Latest Posts

Latest Profile Posts

Guys, I made a trailer! And, I also launched the Steam page! If you would like to support the game, please Wishlist it :ahappy: ->
working on some tilesets _ノ乙(、ン、)_

CIBl8xT.png


Oq8WKHX.png
aww man, color hex code #C4C4C4 doesn't work for the tint value in this scene I need something darker, which stinks just because I liked that one it was my favorite plastic explosive three times...#696969 (nice) should work better (WHY IS MY BRAIN LIKE THIS)
Tell it to me straight, doc. If I've been trying to piece together a "shorter" game to learn stuff outside of game jams... am I just running away from my WIP? :v

Forum statistics

Threads
117,282
Messages
1,106,104
Members
153,460
Latest member
janekste
Top