Rename a File (.png) with script

Oats

Villager
Member
Joined
Jun 26, 2019
Messages
6
Reaction score
0
First Language
English
Primarily Uses
RMMV
Hi, I'm not super familiar with scripting, and I don't see a way to do what I want with the MV.

I'm trying to figure out if there's a way to rename a file, in particular, a png.
is it possible to do this once the game has been compiled?

This is so I can allow the player to choose pre-made characters for Player 1.
Each png will have 8 expressions of one player model. (Player1.png, Player2.png...etc)

Then have the player choose a Character, i.e. Player 3, and I can just rewrite Player3.png to Player1.png
Not sure if this is enough information.
Thanks!

Oats
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,092
First Language
English
Primarily Uses
RMMV
Using the Node Filesystem module you can rename files:

https://nodejs.org/api/fs.html#fs_fs_rename_oldpath_newpath_callback

Note this only works for desktop deployments and it permanently overwrites the file. If Player3.png is renamed to Player1.png then the old Player1.png is completely gone. And if the player starts a new game, there is no Player3.png anymore.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,662
Reaction score
1,112
First Language
EN
Primarily Uses
RMMV
Alternatively, based on what you've said, you may want to consider using the Change Actor Images event command to change the faceset associated with that actor. Then you can use a plugin like Yanfly's Message Core + Extended Message Pack 1 or Shaz's More Escape Codes to specify the face index (i.e. the facial expression) via a message code. :)

Also, in case it comes in handy: you can have more than 8 faces per faceset if you manually edit the image. Just add more rows (144 px row height) and the editor should recognise them! :kaothx:
 

Oats

Villager
Member
Joined
Jun 26, 2019
Messages
6
Reaction score
0
First Language
English
Primarily Uses
RMMV
Wow, both excellent and informative answers. Thanks a lot Aloe and caethyril! I will try them soon

Oats
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Turns out 4 layers is A LOT.
I noticed random Japanese dialogue in the FF7 remake while playing in English. More than once. Just now I saved a vid where Tifa spoke Japanese after a battle. We all make mistakes lol, this is kinda funny though
I wonder if the new RPG Maker will have a built-in ABS for maps or a light effect system plugin out of the box.
Not having false expectations, but if it has both, then wow. I am gonna party all night. Nah I lie. I will party all night anyway, just searching for a good excuse. :stickytongue:
And BAM!, the moment you do understand Python setters by studying JS prototypes. That's called SERENDIPITY, coming with something when you was searching for something else. From "The three Princes of Serendib", a persian novel.
The sinking feeling when you realize your grandmother probably isn't long for this world, and the frustration when you know that this pandemic will take her away...not because she has Covid, but because no doctor is willing to see a patient to even run simple diagnostics anymore if one of her symptoms happens to be a recurring fever, even if her primary care physician gives her the test and it comes back negative.

Forum statistics

Threads
99,620
Messages
967,369
Members
131,293
Latest member
florencesnow
Top