[Solved] Firing a common event every time a message window is shown

Oatilis

Veteran
Veteran
Joined
Mar 16, 2016
Messages
30
Reaction score
8
First Language
Hebrew
Primarily Uses
Hey,
I want to have a common event fire each time the player sees a message, or any new window for that matter.
I know the "reserveCommonEvent" method, just not really sure where to use it:

$gameTemp.reserveCommonEvent

Tried the scene manager code, but couldn't get a consistent result.
Please advise :)
 
Last edited:

hinola

Veteran
Veteran
Joined
Jun 27, 2015
Messages
49
Reaction score
67
First Language
Français
Primarily Uses
RMVXA
Every messages, or every windows ?

Because there will be many windoiws, and even windows that are created, but not shown
Like gold window on map for exemple
 

Oatilis

Veteran
Veteran
Joined
Mar 16, 2016
Messages
30
Reaction score
8
First Language
Hebrew
Primarily Uses
Every messages, or every windows ?

Because there will be many windoiws, and even windows that are created, but not shown
Like gold window on map for exemple
Thanks for the reply!

I need the event to fire every time a new window is shown.
(It can be before the window actually shows).

Preferably, it would fire before every window is shown, i.e. gold window, messages, menus, selection windows, battles, etc. If it's only message windows, I can make it work too.
 
Last edited:

hinola

Veteran
Veteran
Joined
Jun 27, 2015
Messages
49
Reaction score
67
First Language
Français
Primarily Uses
RMVXA
With the test I made, $gameTemp.reserveCommonEvent will run the event after the text box is closed, or the next time a common event can be started

I guess I can do it on the command "show text" to call the event before showing the window, but not more.
I don't know MV and javascript enough to make bigger changes :/
 

Eliaquim

Raze: The Rakuen Zero's Guardian!
Veteran
Joined
May 22, 2018
Messages
1,269
Reaction score
543
First Language
Portuguese - Br
Primarily Uses
RMMV
I think I can make it... but I need to know what exactly you want to do with this. Why do you have to fire a common event before every window is open? It is a unique common event or it has to be a different common event for every window?
 

Oatilis

Veteran
Veteran
Joined
Mar 16, 2016
Messages
30
Reaction score
8
First Language
Hebrew
Primarily Uses
I think I can make it... but I need to know what exactly you want to do with this. Why do you have to fire a common event before every window is open? It is a unique common event or it has to be a different common event for every window?
It's just one. I'm using it to clear some UI elements when windows show. I'm going to have the common event ID hardcoded, no need to change it.
 

Oatilis

Veteran
Veteran
Joined
Mar 16, 2016
Messages
30
Reaction score
8
First Language
Hebrew
Primarily Uses
I guess I can do it on the command "show text" to call the event before showing the window
I couldn't find a method called "showText" anywhere.
Where did you look?

Edit: Tried with "createMessageWindow" (in scenes), but it was unsuccessful. The common event wasn't called. It makes sense because this is not where windows are opened (I guess), but created. Unlike a bunch of shop, battle and item windows, I couldn't find anything like "messageWindow.activate()" or "messageWindows.open()".
 
Last edited:

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,089
Reaction score
1,042
First Language
Spanish
Primarily Uses
RMVXA
set the common event to parallel, and add a condition to watch $gamemessage.hastext == true.
on true, validate; on false, exit event.


(hasText, isBusy, or whatever condition works best. The point being, you can watch the global object $gameMessage, which is there for that purpose)
 

Eliaquim

Raze: The Rakuen Zero's Guardian!
Veteran
Joined
May 22, 2018
Messages
1,269
Reaction score
543
First Language
Portuguese - Br
Primarily Uses
RMMV
It's just one. I'm using it to clear some UI elements when windows show. I'm going to have the common event ID hardcoded, no need to change it.
So I presume that you want to hide your UI elements when any window is open, perhaps when changing the scene too(like menu scene and battle...)?
And you want to automatically show the UI again after these windows are closed?

[[EDIT]]

set the common event to parallel, and add a condition to watch $gamemessage.hastext == true.
on true, validate; on false, exit event.
I think this can work too. Instead, I will use the script call in the condition: SceneManager._scene._messageWindow.active because I don't know if $gamemessage.hastext works for choice window too.

If returns true, then it plays a common event. Otherwise nothing.

But in case of the menu(or other scenes) the common event plays after the scene. So if you want to erase pictures when you open the menu, the picture only is erased when you close the menu(in fact the picture can be erased before, but the snapshot take in the map scene will still show the picture).

But the problem is: How do you plan to show the UI again?
 
Last edited:

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,089
Reaction score
1,042
First Language
Spanish
Primarily Uses
RMVXA
I don't know if $gamemessage.hastext works for choice window too.
isChoice, then.
hasText, isChoice, isNumberInput, etc.... the object has it's own checks for it's own windows, which are dependent on the message itself.

THE way to do it would be to alias the method and run everything from gamemessage, but if they want to just use the common event, you can still grab the global $gamemessage much easier than the window through the scene.

(I'm trying to get the OP to come up with the solution through common eventing, and then discover they're basically coding an alias method, so they can take that to the code and get rid of the common event altogether... but, husssshhh!)
 
Last edited:

Oatilis

Veteran
Veteran
Joined
Mar 16, 2016
Messages
30
Reaction score
8
First Language
Hebrew
Primarily Uses
$gamemessage.hastext
This works pretty well! Combined with another condition or two, it's exactly what I was going for. Thanks!

Just for reference, for people who might be looking into this in the future, the actual condition is:
$gameMessage.hasText() == true

SceneManager._scene._messageWindow.active
This seems to return true indefinitely. It's a good idea but I couldn't make it work right now. Maybe with some additional tinkering.

How do you plan to show the UI again?
No need.
I'm hiding an optional "quest hint" and the map. The user can display them at any time, but I don't want them interfering with dialogue and menus. A lot of my dialogue is in speech bubbles so things can get in the way and it looks messy. If the player wants to see them again, they can just press the map button.

I think this is pretty much solved. Thanks everyone!
 

Oatilis

Veteran
Veteran
Joined
Mar 16, 2016
Messages
30
Reaction score
8
First Language
Hebrew
Primarily Uses
(I'm trying to get the OP to come up with the solution through common eventing, and then discover they're basically coding an alias method, so they can take that to the code and get rid of the common event altogether... but, husssshhh!)
Haha just saw this.
I'm a programmer but JS is not my strong suite - also, some of the flow of the code in the MV engine is still not 100% clear to me. I wrote a few very basic plugins, but I need to brush up on JS before attempting something like this.
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
2,921
Reaction score
3,951
First Language
English
Primarily Uses
RMMV

@Oatilis , please avoid double posting, as it is against the forum rules. You can review our forum rules here. Thank you.

 

hinola

Veteran
Veteran
Joined
Jun 27, 2015
Messages
49
Reaction score
67
First Language
Français
Primarily Uses
RMVXA
Be careful when using common events like this, if a command take resources you can have fps drops.

You should use a switch "ui displayed"
A condition "if the message box has text" and a condition "ui displayed is ON"
Then you turn it off and remove your ui

So the deactivation of the ui will be done once and not every frames the message is up.

You can also add a "else" to the first condition, and make the condition "ui displayed is OFF"
In which you can reactivate your ui.
So the player don't have to go on the menu to reactivate it himself
And of course, you can add a condition to verify if the player had it activated before the message.
 

Oatilis

Veteran
Veteran
Joined
Mar 16, 2016
Messages
30
Reaction score
8
First Language
Hebrew
Primarily Uses
[DPOST]@Oatilis [/DPOST]
Noted!

Be careful when using common events like this, if a command take resources you can have fps drops.

You should use a switch "ui displayed"
A condition "if the message box has text" and a condition "ui displayed is ON"
Then you turn it off and remove your ui

So the deactivation of the ui will be done once and not every frames the message is up.

You can also add a "else" to the first condition, and make the condition "ui displayed is OFF"
In which you can reactivate your ui.
So the player don't have to go on the menu to reactivate it himself
And of course, you can add a condition to verify if the player had it activated before the message.
Yeah, I'm already doing this!

The current solution is definitely kind of a hack, it's also a type of polling which I always try to avoid.
That's why I wanted to simply alter the message window code or listen to the event behind the scenes. My game is almost complete and so far I've used zero parallel-common events. I'll make do with the current solution for now but I might come back to it later. I need to start pushing for release instead of making everything perfect, or I'll never finish it.
 
Last edited:

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

Latest Threads

Latest Posts

Latest Profile Posts

Any also thought it's too cringy to put the word "and you" in your credit as a special thanks?
Cause that's what I thought...
Everyone in the US right now: Please stay safe.
Symphony Celestia: Prophecy of the Falling Stars RPG Maker music pack WIP. Symphony Celestia is a new series that focuses on symphonic and orchestrated music to tell a story. Each story will include compositions that make up that story from beginning to end. Themes include: Battles, adventures, character themes, etc. Below is a video preview to the first story.

Jumping and gravitation 0.1 build - RPG Maker MV
It's ironic, but one of the many hilarious things done with Shia's Just Do It speech was to make a hype song, and....I know what it is.....but I still get inspired by it! I'm like..."Yes I can!!"

Forum statistics

Threads
97,975
Messages
948,244
Members
129,227
Latest member
HamadAhli
Top