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,780
Reaction score
1,631
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,780
Reaction score
1,631
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 Profile Posts

I'm feeling rough today, a bit too many last night I'd say. Still have no choice to work on Corpse Mansion. That and I got. bunch of sales last night. I was like wtf this morning, next payout is gonna be nice at least.
I'm just so close to replacing LUK with a different stat, maybe DEX but we'll see.
Slapped together a title screen and working on some dungeon clutter + portraits for Dubhghaill and Einar. Usual CW for minor body horror wrt Einar
QVLJIgD.png

OaPcYUy.png

r55FiUJ.png

EIgO94y.png
cT1V4nb.png
>studying for months for an exam
>does exam
>waits 3 months for the results to come out
>me trying to login, incorrect password
>I get recovery password
>me trying to login, incorrect password

What the heck. As a son of a Karen, I'm going to file a few complaints.

Forum statistics

Threads
117,149
Messages
1,104,971
Members
153,229
Latest member
jimproringtones
Top