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,706
Reaction score
1,591
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,706
Reaction score
1,591
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

So Facebook fraudulently took money from me. They even went through my PayPal accounts to find a card that had the money on it. Thinking about deleting my Facebook account because this doesn't happen on twitter, not even close.
Today the 2nd part of the RPGMakergame "A Thief's voyage" came out.


Go show DutchPowerCreations some love.
love it when you forget to put a certain thing in the movement route and suddenly a character starts spinning at 10000 rpm
I'm sorry. I have a bad feeling I've been manic the past couple of days. Antidepressants have only been making things worse somehow -- too drowsy to function, followed by insomnia. Why not making me go crazy to boot?
Cosmetix.gif

Hey man, why don't you do some progress on your game? Oh, because you'd rather wake up at 5am and spend the night making a cosmetics system for your side view battlers? Ok.

Forum statistics

Threads
116,992
Messages
1,103,635
Members
152,882
Latest member
Nextosam
Top