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,627
Reaction score
1,061
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,394
Reaction score
872
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

I bought a 2 week emergency food supply. And people are already making fun of me :( I'll be fed for a bit while they go hungry when food supplies get cut(for whatever reason).
Start of semester today. This is going to be a long one.
Can't wait for the next Sonichu
Birdhouses are usually made of wood. Birds typically live in trees. Trees are wood. Birdhouses are made of birdhouses.
He just discovered cellphones...

(I don't know why am I drawing so much these days...)

Forum statistics

Threads
93,673
Messages
914,477
Members
123,264
Latest member
DoritoDiet
Top