Save and Use Screenshot?

Hi All,

I'm working on making a custom menu with events and,
I was wondering if someone could either guide me to one I may of missed in my searching, or help create a plugin for me that does the following:

When the player is outside of battle and presses the button I assign, the game takes an auto screenshot (without telling the player preferably) of what the player currently sees and have it overwrite an image in my Parallax Background image folder.

This would allow me to set the map my menu is on to have a preset Parallax Background that constantly changes and displays at all times the same area the player is in. 

...

The closest I've seen is Hudell's...




But I don't believe it does quite what I want it to do.

Thanks!
There is a much easier way to do this.  There's already a function that takes a snapshot of the map background, and it's used by Scene_MenuBase.createBackground.  It gives you a blurred image, but if you can work your way through how it's created and used (rpg_scenes.js and SceneManager in rpg_managers.js) it shouldn't be too difficult to add a couple of functions that provide an unblurred image.
Hi Shaz,

Thanks for the response.

I'm pretty inexperienced so far in scripting, so to a novice like I'm still not entirely sure how to.  I've been trying to fiddle around with some functions but, I just can't seem to get a grasp on it.  Unfortunately I haven't really gotten anywhere with it yet.

Part of the problem is that, I want the image to display as on a map without bringing the menu up because the menu I'm using is entirely made with events.
 
Might be an issue using it as a parallax background, because the images are cached.  If it sees that you've already used that image once in the current playthrough, it won't reload it the next time you want it - it'll just show the last one you used.
Hi Shaz,

Thanks for the response.

I'm pretty inexperienced so far in scripting, so to a novice like I'm still not entirely sure how to.  I've been trying to fiddle around with some functions but, I just can't seem to get a grasp on it.  Unfortunately I haven't really gotten anywhere with it yet.

Part of the problem is that, I want the image to display as on a map without bringing the menu up because the menu I'm using is entirely made with events.
 



So, let me get this  straight -- you want a the game to overwrite a picture in your parallax folder?


Or the other option being taking a screenshot of the map the player is on and having your parallax  change once the picture is taken?


The issue though I assume, is that you're calling an image from your folder, so the latter option isn't the best choice?


Either way,  maybe I can help you.
So, let me get this  straight -- you want a the game to overwrite a picture in your parallax folder?


Or the other option being taking a screenshot of the map the player is on and having your parallax  change once the picture is taken?


The issue though I assume, is that you're calling an image from your folder, so the latter option isn't the best choice?


Either way,  maybe I can help you.

Hi Kino,

I just figured that would be the easiest.  But, whichever way works best.

Basically, the game takes a screenshot of the what the player sees when they press the button (I have a common event set to "C") then the game takes note of the player's "Current Map ID", and "Current X" and "Current Y" coordinates.  

Next, the player is transferred to a different map, on this map, I want the background for this map to be replaced with the screenshot.  But the player still needs to be visible and able to walk over top of the picture.

When the player presses the "C Button" again, the player is taken back to the map and coordinates within stored in the variables, the screenshot disappears and is replaced by a new one each time the player transfers to that other map.

I hope didn't mangle my description too bad.

And thanks for the offer of help, I appreciate it 🙂.
I will look into it; I have an idea.


Different timezone;  need some rest. Lol


@Eilwyn




The transfers are something you can do, but my plugin does let you map a button to a screenshot button. 
Or you can force the game to take a screenshot, but this one has the player on it. 
 


I tried changing quite a few different settings, but I can't seem to find a workaround for this -- unfortunately.


The only way I can see of getting this to work properly is to either create the images, or name the screenshots in a set of events, then load the parallax as the player gets to the map.


Sorry I couldn't help much.
@Kino

Sounds awesome!  I have an event set up that transfers the player already when they press the button and it is set up as a "Parallel Process" Common Event.  Will it still be able to work along side your plugin?  Or will  I have to alter the Common Event or make a whole new event or etc... around the plugin?

And I appreciate the effort you're putting into this 🙂
@Eilwyn


I like to make sure things work when I offer my help to people, so no worries there. 
I can come up with an idea using what @Shaz recommended.

  1. Create a common event that takes a screenshot with a specified name
  2. Load the screenshot into the cache'd screenshot's place
  3. Be happy, cause it should work now.

I haven't tested this, but I do know if you try to load a different image into the same spot / name for the parallax. 
It will update itself to reflect the changes.

If you want; I can also make it so it's a list of screenshots that you can access by index and reload your parallax before the player gets there.
@Kino


That sounds great, if you can get it to work 🙂

And as for the last bit, I don't think I need the list of screenshots, just the one that keeps overwriting the one parallax file... that should do enough for what I need ^^.
Okay, I have a solution; it's now built into my Screenshot plugin so here!
It's kind of an extension. @Eilwyn


Here: View attachment EISScreenShots.js


Okay, so first step you're going to want to set the path to the parallax you want to overwrite.


Also note: The path is case sensitive, so if you're file name is "TEsT", you'll have to do like the below except as "TEsT.png".


So you're going to call it like below for example:


/*
* KR.cacheBitmapPath("img/parallaxes/Test.png");
*/


EISScreenShots1.png


After that, on the map you want to overwrite the parallax on, make sure it's set to whatever parallax you want to overwrite as the default.


In my case it would be Test below.


EISScreenShots2.png


Finally:


In your common event you're going to want to put.


KR.replaceBitmap(KR.getCachedBitmap());
//This will replace the bitmap temporarily while the game is running in the cache.




Just some plugin things lastly. For your case, you want to press the key O, or change it to a default key that you prefer to take a screenshot. 
Or, you can call: 


KR.takeCleanScreenShot();
//This will take a clean screenshot without any characters on the map, or anything, and save the bitmap in a cache for easy replacement via
//KR.replaceBitmap --


That function will do the same thing as pressing a key, so you can call it in your common event to do just that.
@Kino

I'm having a little bit of trouble getting it to work.

When I use add "KR.takeCleanScreenShot();" to the Common Event, I get: 

"TypeError: Cannot read property 'keyCode' of undefined"
@Eilwyn


Sorry about that; here you go:


View attachment EISScreenShots.js


That should work now!
@Kino


No worries.

Now, I can get into the menu, but it doesn't change to the screenshot... just shows the placeholder image. (which I called "!Menu.png", which is just a solid blue colour.

Also now when I leave my menu, I get a new error I never got before, and the Common Event that controls this worked perfectly beforehand, so maybe something to do with the Plugin?

Anyway, the error is:

"TypeError: Cannot read property 'isAppeared' of null"


I have no idea why.

This is what I have:

COMMON EVENT (2 pictures because it is too big for one pic)
2016-06-30%207_zpsutwokgzs.png

2016-06-30%208_zpsojwyl89x.png


The event on the map I want the screenshot to transfer to (Page 2 just tells it to do nothing as long as the switch is on)
2016-06-30%208_zpsojwyl89x.png


EDIT: Sorry if you saw this while the images were blurred, I've so, I've fixed them so they aren't blurred.
Okay, I would move the KR.cacheBitmapPath to the top of your common event.
That way it can set the path before your common event runs, or tries to replace the bitmap. It won't replace unless it knows what path it's on.


One other thing is are you taking your screenshot on the map before fading out?


@Eilwyn
The next thing is; can you open the dev console for me? 
I believe the button is F8 on the keyboard. Take a screenshot, and I should be able to find out where the problem is.

And just open it up and see where it says the uncaught error occurred. From what I can tell, isAppeared is a function of game characters.
2016-06-30%209_zpsnql2in6i.png


And I moved both commands to the top of the common event.   Still goes to the map, but still doesn't update or at least doesn't change the image.
Wait, where's the KR.cacheBitmapPath("img/parallaxes/!Menu.png") in the common event?


That's the one you want at the top of the common event.
That's on the Map that I want the image to appear as the background on.
@Eilwyn


Alright, so that's the one you definitely want at the top of the common event, because it sets the path, so the script can replace the picture. 
If it's on the menu map it won't do anything.

About your error; it has something to do with the Game_Actors
I think it might be the script tag for adding game actors; one of the variables might be null.
So sorry but, I seemed to be confused now as to where I'm supposed to add everything, even after re-reading you're previous post.

I now have:

KR.cacheBitmapPath("img/parallaxes/!Menu.png")
KR.takeCleanScreenshot();

&

KR.replaceBitmap(KR.getCachedBitmap());

So, where all do I place these?  

Do I place them all on the common event and only the common event?  Or do I still have to add something to the map itself?

I think the reason I got confused is because, your one screenshot example has them being placed within an event on a map and then for the next part of that post, you mention to put the next thing into the Common Event... and now unless I've bungled this all up somehow, I'm really supposed to add things in different places than I thought?

Sorry about all this noobish-ness, I'm still getting a hang on all this scripting and all the related mechanics.

Thanks for your patience though 🙂
 

Original thread: https://forums.rpgmakerweb.com/threads/save-and-use-screenshot.64387/