Changing Opacity of an Event via Variable

Long story made short, I want to make an event seemed to slowly fade in. The method I came up with would, theoretically, be using the Set Move Route function to:
-Change the opacity based on a variable (I'm using the second one specifically)
-Wait a frame
Then simply change the value of the variable. The problem is that I can't figure out how to change the opacity based on a variable. If anyone knows how to do that, or a more efficient way of achieving the same result, I'd appreciate the help. 🙂
Why do you want to use a variable, if it's the move route that's going to change it? Why not just change the opacity directly, to the current opacity + or - a given amount?

How are you going to tell it when to start fading in, and when to stop? Is it a part of a cutscene that needs things to happen before and after?

If you have a cutscene controller, and the event you want to fade in is a different event, then set up your event to have no sprite. If you want this character to stay around after the player leaves the map and returns, or you want to be able to interact with it after, add a second page with the sprite, conditioned by a switch.

Now in your controller, at the time you want the character to appear, do 2 move route commands. The first will be:
Code:
Set Move Route: [EV001] (Wait)
                Change Opacity: 0
                Change Graphic: (select character and index)

then the second, immediately after, will be:
Code:
Set Move Route: [EV001] (Wait)
                Script: @opacity = [@opacity + 20, 250].min
                Wait 5 frames
                Script: @move_route_index = -1 if @opacity < 250

The above commands will make the NPC invisible and set the correct graphic (do it in that order), and the second one will gradually fade in, looping until the fadein is complete. After it's complete, the event will continue with the next command, which should be to turn on the switch to activate the second page of the event.

You can change the 20 and the 5 to alter the fade in rate, and of course EV001 should be whatever event it is that you want to fade in.
Why do you want to use a variable, if it's the move route that's going to change it? Why not just change the opacity directly, to the current opacity + or - a given amount?
Eh... mostly not knowing any better. I didn't know one could reference the opacity of an event just like one would do with a variable.

How are you going to tell it when to start fading in, and when to stop? Is it a part of a cut scene that needs things to happen before and after?
The initial plan had been to do it as I had described it before, but with a loop and conditional and... blah blah blah, yes, it is part of cut scene.

Thanks, it worked!
I asked about the variable because I wanted to know if you were using it for something else as well, and needed it to use the variable because opacity isn't the only thing being controlled by it.

If you need it to be triggered and ended some other way, just say so. Because you didn't describe the context I just made some assumptions, which could be wrong.

But if it does what you need, and no tweaking is necessary, just report your first post and let the mods know the question has been answered, and they'll close the thread for you.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/changing-opacity-of-an-event-via-variable.113534/