Mark91

Veteran
Veteran
Joined
May 19, 2017
Messages
160
Reaction score
20
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
7,629
Reaction score
5,395
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
160
Reaction score
20
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
7,629
Reaction score
5,395
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
160
Reaction score
20
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
25
Reaction score
21
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

I've got good news and bad news. The good news is, there aren't any bad news to report. The bad news is, there aren't any good news to report.

Or as others say, yesterday was uneventful.


I am curious that can you "understand/get the point" about what does this place do generally?
(ARPG game)
If anyone knows any C# programmers, please send them my way.
Chilling at night in a tavern.
ChillingAtTavern.png

After 'multiple breakdowns', it's finally over. 10/10 will do this again.
Ever notice that villains can reform and become better people, but heroes can only ever die... or live long enough to see themselves become villains?

Isn't that interesting?

Forum statistics

Threads
129,844
Messages
1,205,659
Members
171,001
Latest member
OliguS
Top