Allinardo

Dungeon Crawler
Veteran
Joined
Jan 2, 2013
Messages
60
Reaction score
23
First Language
English
Primarily Uses
A while back I came across an event-based UI character creator in a RPG Maker MV game, and I couldn't help but wonder how it was done. I forgot about it over time, and don't even remember the name by now, but the thought came back to me recently while working on my current project.

From what I could gather, he seemed to take a screenshot of the character you made in his custom UI and save the image under a specific name into the images folder.


I can't seem to find a built-in screenshot function that works anything like this, so does anyone know if there's something in javascript you could do? Or am I overlooking something within RPG Maker MV itself?

If not, then please move this to script requests. Thanks in advance.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,495
Reaction score
14,825
First Language
English
Primarily Uses
RMMV
It would not be a screenshot function.  It would have been creating a new bitmap by combining lots of other bitmaps of all the parts, and then saving it as a png file.  Not sure what functions MV has that would allow that.  Previous makers needed to have additional libraries added for the extra functionality.
 

Lantiz

PunyMagus
Veteran
Joined
Dec 29, 2012
Messages
723
Reaction score
1,075
First Language
Portuguese
Primarily Uses
Other
You can blit the character bitmap to another bitmap to build it as it must be stored and save it using something like this:

Code:
function saveCharacter(bitmap, filename) {
  var fs = require('fs');
  var dir = window.location.pathname.replace(/(\/www|)\/[^\/]*$/, '/');

  if (dir.match(/^\/([A-Z]\:)/)) {
  	dir = dir.slice(1);
  }

  var fileName = decodeURIComponent(dir) + 'img/characters/' + encodeURIComponent(filename + '.png');
  var image64 = bitmap._canvas.toDataURL().replace(/^data:image\/png;base64,/, "");

  fs.writeFileSync(filename, image64, 'base64');
};
 

Allinardo

Dungeon Crawler
Veteran
Joined
Jan 2, 2013
Messages
60
Reaction score
23
First Language
English
Primarily Uses
It would not be a screenshot function.  It would have been creating a new bitmap by combining lots of other bitmaps of all the parts, and then saving it as a png file.  Not sure what functions MV has that would allow that.  Previous makers needed to have additional libraries added for the extra functionality.

Ah I figured it was probably that, though I wasn't sure because of how explained it in his demo. A bit more complicated than just a simple screenshot, but I know how it works now at the very least, along with the specific javascript functions required.


I was honestly just hoping someone knew a shortcut. Ah well. Thanks you!
 

Allinardo

Dungeon Crawler
Veteran
Joined
Jan 2, 2013
Messages
60
Reaction score
23
First Language
English
Primarily Uses
You can blit the character bitmap to another bitmap to build it as it must be stored and save it using something like this:



function saveCharacter(bitmap, filename) {
var fs = require('fs');
var dir = window.location.pathname.replace(/(\/www|)\/[^\/]*$/, '/');

if (dir.match(/^\/([A-Z]\:)/)) {
dir = dir.slice(1);
}

var fileName = decodeURIComponent(dir) + 'img/characters/' + encodeURIComponent(filename + '.png');
var image64 = bitmap._canvas.toDataURL().replace(/^data:image\/png;base64,/, "");

fs.writeFileSync(filename, image64, 'base64');
};

This is simpler than the code I worked out, though the UI my friend and I made has some 15-20 layers so maybe it just looks simpler. I'll try this out and see how it works.
 

Lantiz

PunyMagus
Veteran
Joined
Dec 29, 2012
Messages
723
Reaction score
1,075
First Language
Portuguese
Primarily Uses
Other
Looks good, tell me if this work  :)
 

Allinardo

Dungeon Crawler
Veteran
Joined
Jan 2, 2013
Messages
60
Reaction score
23
First Language
English
Primarily Uses
It doesn't appear to work properly at all...however rather than the game crashing like my script did(after freezing up for 5 seconds), yours just doesn't appear to do...anything. At least for me. Perhaps I'm using it wrong?

My script had selected a set number of pictures from the 'img/pictures' folder based on about 20 variables.
So let's say variable 1 is 1, then it would pick "1-1.png"
If variable 5 is 2, then it'd pick "5-2.png".

Is there a way to shorten that all down, as well as compress all the selected pictures into a single image? Because I thought I knew but that just made it crash.
 
Last edited by a moderator:

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,699
Reaction score
940
First Language
English
Primarily Uses
N/A
How exactly are you calling the function when it does nothing? 
 

Allinardo

Dungeon Crawler
Veteran
Joined
Jan 2, 2013
Messages
60
Reaction score
23
First Language
English
Primarily Uses
I tried a few ways. Firstly through an event, then as an external plugin itself and giving it its own plugin command, then running it through my own plugin that can call scripts in bulk but only calling that individual script. Wanted to see what worked, what didn't.
 
Last edited by a moderator:

Lantiz

PunyMagus
Veteran
Joined
Dec 29, 2012
Messages
723
Reaction score
1,075
First Language
Portuguese
Primarily Uses
Other
Maybe its not finding the directory path, try saving in another place for testing purposes.


I use a similar function in a plugin and it works fine.
 

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,699
Reaction score
940
First Language
English
Primarily Uses
N/A
What did you use as the script call in the event? Can you copy/paste the code you used?
 

Allinardo

Dungeon Crawler
Veteran
Joined
Jan 2, 2013
Messages
60
Reaction score
23
First Language
English
Primarily Uses
Maybe its not finding the directory path, try saving in another place for testing purposes.


I use a similar function in a plugin and it works fine.



Ah that wasn't it. I tried it in a different project and it worked just fine. I guess there's something either blocking the script, a script conflict(doubt it), or my project is just bugged. I'll figure it out on my own from here. Thanks a bunch :D
 

Lantiz

PunyMagus
Veteran
Joined
Dec 29, 2012
Messages
723
Reaction score
1,075
First Language
Portuguese
Primarily Uses
Other
I see... well good luck [:
 

Latest Threads

Latest Posts

Latest Profile Posts

I've been in Fort Myers since Thursday night. I'm going home tomorrow or the next day... lol, I desperately need a good taste of homemade Japanese food. I might not be Japanese or even Asian (I'm American born and raised), but I absolutely love authentic Japanese cooking. Restaurant food doesn't do it justice.
Haven't been working on any of my projects or resources lately as I'll soon be moving to a new apartment. It's been a stressful move but I'm really looking forward to it.
//Sees it's the same price at Best Buy for a new SSD as Amazon
//Sees it's 103F outside and Best Buy is half a hour of driving.
//Orders from Amazon.
I'll wait the 2-3 days. :LZSwink:
Just a little teaser screenshot of Mountain Village...

Screenshot (364).png

Forum statistics

Threads
112,373
Messages
1,067,869
Members
146,025
Latest member
urmomsbigbazoongas
Top