MZ How to refresh game

So, I'm trying to use VisuMZ Proximity Compass with ABS system, and it's working great.
Though, I'm facing a problem with spawned enemies.
I find out that the minimap don't update their icon if new event just spawn in the map, but only when the menu button is pressed and quit, then the icon of my spawned enemies just shown up.
What I'm asking here is, how can I "refresh" my game, so that the enemies are show in my minimap, without using something like SceneManager.goto(Scene_Map)? And that's because, the screen became black (mid-battle) and for a player could be a little bit of unnerving.
I hope that I'm posting in the right thread, and I wish you a nice and merry Christmas!
Bip.
So, no one can help with that one? I still can't find a solution too...
I have moved this thread from RPG Maker MZ Support to JavaScript/Plugin Support.

Posting on Christmas and New Year's Eve may have really hid this one! So. I do not know much (read: anything) about plugins, but screen shots that illustrate this issue will likely be a fantastic starting point for anyone who gets eyes on this.
for MV there is $gameMap.requestRefresh() function and one for you could
try on the spawn event to see if that works.

I dont know if its the same for MZ, but you can try to search in the rmmz_objects
for Game_Map property to see if that works.

for some parts it can help or $gameMap.requestRefresh(this._MapId), but this one
is something I didn't test though as the normal should work fine.

if MZ has a different part, look that up and use it on page 1 before doing all the
other stuff on page 2 and forward, otherwise, I dont know how spawned events
exactly works with the compass.
I have moved this thread from RPG Maker MZ Support to JavaScript/Plugin Support.

Posting on Christmas and New Year's Eve may have really hid this one! So. I do not know much (read: anything) about plugins, but screen shots that illustrate this issue will likely be a fantastic starting point for anyone who gets eyes on this.
Yeah that's right, thanks 😅
For something to illustrate my problem, I'm attaching a video for reference, maybe it can help much better.
for MV there is $gameMap.requestRefresh() function and one for you could
try on the spawn event to see if that works.

I dont know if its the same for MZ, but you can try to search in the rmmz_objects
for Game_Map property to see if that works.

for some parts it can help or $gameMap.requestRefresh(this._MapId), but this one
is something I didn't test though as the normal should work fine.

if MZ has a different part, look that up and use it on page 1 before doing all the
other stuff on page 2 and forward, otherwise, I dont know how spawned events
exactly works with the compass.
Tried both of them, but sadly didn't help... But thanks for those tips!


Here is how it works right now, how the enemies are show in my compass, but only after the menu is pressed (like "refreshed")
I don't understand what give this process, and how is made, but I need something to force that to refresh my compass and show those spawned enemies...
If more information is needed, just ask right away, and thanks! 😤
I guess you could just create a new temporary scene and immediately exit it. Try this:
JavaScript:
SceneManager.push(Scene_Base);
SceneManager.pop();
It should have a similar effect to opening and closing a menu. I only tested it in MV, but it should work in MZ too.
I guess you could just create a new temporary scene and immediately exit it. Try this:
JavaScript:
SceneManager.push(Scene_Base);
SceneManager.pop();
It should have a similar effect to opening and closing a menu. I only tested it in MV, but it should work in MZ too.
Yeah, that's working, but there is a small problem with this one; it faded with a black screen... If there is a way to "toggle" it off, it would be perfect.
Yeah, that's working, but there is a small problem with this one; it faded with a black screen... If there is a way to "toggle" it off, it would be perfect.
Well, it's cool that it mostly worked, but a shame that not entirely. It doesn't do a fade-out in MV, so I'm afraid I can't really help with that.

Anyone that knows MZ: is there any way to disable fading out on scene transition?
Alternatively you could try:
JavaScript:
SceneManager.goto(Scene_Map);
This clears the scene stack and just puts you on a new Scene_Map instance.

Problems might be due to your plugins. By default in MV/Z, the map scene decides whether to fade in on start based on the previous scene (cf needsFadeIn, rmmz_scenes.js). Without plugins, it will only fade in if returning from Scene_Battle or Scene_Load.

This might work to disable all map fade-ins, including stuff from Transfer Player (untested):
Spoiler: plugin code
JavaScript:
/*:
 * @target MV MZ
 * @plugindesc Suppress map fade-in.
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/threads/164131/
 * @help Free to use and/or modify for any project, no credit required.
 */
;void (alias => {
'use strict';

  /**
   * @param {Scene_Map} scene Reference scene instance.
   * @returns {boolean} `true` iff should suppress scene fade-in.
   */
  const shouldSuppressMapFadeIn = function(scene) {
    return true;
  };

  const alias = Scene_Map.prototype.needsFadeIn;
  Scene_Map.prototype.needsFadeIn = function() {
    if (shouldSuppressMapFadeIn(this))
      return false;
    return alias.apply(this, arguments);
  };

})();
Currently shouldSuppressMapFadeIn just says "suppress all map fades". I've deliberately separated it like that so it's easier to customise.

[Edit: this has a small typo, see Mac's post below.]
Alternatively you could try:
JavaScript:
SceneManager.goto(Scene_Map);
This clears the scene stack and just puts you on a new Scene_Map instance.

Problems might be due to your plugins. By default in MV/Z, the map scene decides whether to fade in on start based on the previous scene (cf needsFadeIn, rmmz_scenes.js). Without plugins, it will only fade in if returning from Scene_Battle or Scene_Load.

This might work to disable all map fade-ins, including stuff from Transfer Player (untested):
Spoiler: plugin code
JavaScript:
/*:
 * @target MV MZ
 * @plugindesc Suppress map fade-in.
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/threads/164131/
 * @help Free to use and/or modify for any project, no credit required.
 */
;void (alias => {
'use strict';

  /**
   * @param {Scene_Map} scene Reference scene instance.
   * @returns {boolean} `true` iff should suppress scene fade-in.
   */
  const shouldSuppressMapFadeIn = function(scene) {
    return true;
  };

  const alias = Scene_Map.prototype.needsFadeIn;
  Scene_Map.prototype.needsFadeIn = function() {
    if (shouldSuppressMapFadeIn(this))
      return false;
    return alias.apply(this, arguments);
  };

})();
Currently shouldSuppressMapFadeIn just says "suppress all map fades". I've deliberately separated it like that so it's easier to customise.
I wanted to test it, but give out an error
Identifier 'alias' has already been declared on line 19
I wanted to test it, but give out an error
Looks like the argument alias is redundant here, try this:
Spoiler: Plugin code 2
JavaScript:
/*:
 * @target MV MZ
 * @plugindesc Suppress map fade-in.
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/threads/164131/
 * @help Free to use and/or modify for any project, no credit required.
 */
;void (() => {
'use strict';

  /**
   * @param {Scene_Map} scene Reference scene instance.
   * @returns {boolean} `true` iff should suppress scene fade-in.
   */
  const shouldSuppressMapFadeIn = function(scene) {
    return true;
  };

  const alias = Scene_Map.prototype.needsFadeIn;
  Scene_Map.prototype.needsFadeIn = function() {
    if (shouldSuppressMapFadeIn(this))
      return false;
    return alias.apply(this, arguments);
  };

})();
Looks like the argument alias is redundant here, try this:
Spoiler: Plugin code 2
JavaScript:
/*:
 * @target MV MZ
 * @plugindesc Suppress map fade-in.
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/threads/164131/
 * @help Free to use and/or modify for any project, no credit required.
 */
;void (() => {
'use strict';

  /**
   * @param {Scene_Map} scene Reference scene instance.
   * @returns {boolean} `true` iff should suppress scene fade-in.
   */
  const shouldSuppressMapFadeIn = function(scene) {
    return true;
  };

  const alias = Scene_Map.prototype.needsFadeIn;
  Scene_Map.prototype.needsFadeIn = function() {
    if (shouldSuppressMapFadeIn(this))
      return false;
    return alias.apply(this, arguments);
  };

})();
So, I tried this new one, and I don't know if is properly working... I'm using it alone, without any other plugin active, but it doesn't trigger the fadeout off... 😅

So, I tried this new one, and I don't know if is properly working... I'm using it alone, without any other plugin active, but it doesn't trigger the fadeout off... 😅
Update: I've tried in a new and fresh project, but the problem is here too.
With or without, when I use
JavaScript:
SceneManager.push(Scene_Base);
SceneManager.pop();
or
JavaScript:
SceneManager.goto(Scene_Map);
it's always the same; black screen and then show my map.
Whoops, thanks Mac! 👋

It looks like it's actually entirely related to fade out, sorry. 😴 I tested this time, try this instead:
Spoiler: plugin code v2 (suppress fade out)
JavaScript:
/*:
 * @target MZ
 * @plugindesc Suppress fade-out on map transfer.
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/threads/164131/
 * @help Free to use and/or modify for any project, no credit required.
 */
;void (() => {
'use strict';

  /**
   * @param {Scene_Map} scene Reference scene instance.
   * @returns {boolean} `true` iff should suppress scene fade-in.
   */
  const shouldSuppressMapFade = function(scene) {
    return true;
  };

  const aliasOut = Scene_Map.prototype.fadeOutForTransfer;
  Scene_Map.prototype.fadeOutForTransfer = function() {
    if (!shouldSuppressMapFade(this))
      aliasOut.apply(this, arguments);
  };

//  const aliasIn = Scene_Map.prototype.fadeInForTransfer;
//  Scene_Map.prototype.fadeInForTransfer = function() {
//    if (!shouldSuppressMapFade(this))
//      aliasIn.apply(this, arguments);
//  };

})();
Whoops, thanks Mac! 👋

It looks like it's actually entirely related to fade out, sorry. 😴 I tested this time, try this instead:
Spoiler: plugin code v2 (suppress fade out)
JavaScript:
/*:
 * @target MZ
 * @plugindesc Suppress fade-out on map transfer.
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/threads/164131/
 * @help Free to use and/or modify for any project, no credit required.
 */
;void (() => {
'use strict';

  /**
   * @param {Scene_Map} scene Reference scene instance.
   * @returns {boolean} `true` iff should suppress scene fade-in.
   */
  const shouldSuppressMapFade = function(scene) {
    return true;
  };

  const aliasOut = Scene_Map.prototype.fadeOutForTransfer;
  Scene_Map.prototype.fadeOutForTransfer = function() {
    if (!shouldSuppressMapFade(this))
      aliasOut.apply(this, arguments);
  };

//  const aliasIn = Scene_Map.prototype.fadeInForTransfer;
//  Scene_Map.prototype.fadeInForTransfer = function() {
//    if (!shouldSuppressMapFade(this))
//      aliasIn.apply(this, arguments);
//  };

})();
Yeah, that's work now! I just have one problem now, and is in my original game. I tried to edit the code to "activate" this plugin, but I think that my little JavaScript knowledge isn't helping that much lmao.

Spoiler: edited code
JavaScript:
/*:
 * @target MZ
 * @plugindesc Suppress fade-out on map transfer.
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/threads/164131/
 * @help Free to use and/or modify for any project, no credit required.
 */
if ($gameSwitches.value(47) == true) {
  ;void (() => {
    'use strict';

  /**
   * @param {Scene_Map} scene Reference scene instance.
   * @returns {boolean} `true` iff should suppress scene fade-in.
   */
  const shouldSuppressMapFade = function(scene) {
    return true;
  };
      const aliasOut = Scene_Map.prototype.fadeOutForTransfer;
      Scene_Map.prototype.fadeOutForTransfer = function() {
        if (!shouldSuppressMapFade(this))
          aliasOut.apply(this, arguments);
  };

//  const aliasIn = Scene_Map.prototype.fadeInForTransfer;
//  Scene_Map.prototype.fadeInForTransfer = function() {
//    if (!shouldSuppressMapFade(this))
//      aliasIn.apply(this, arguments);
//  };

})();
}
[/ICODE][/SPOILER]
Can something like that be done? I need it because, when i teleport meanwhile this plugin is active, it crashes my game. If you have an idea for that, would be very nice! Because it works very well with the fresh project, and I think that we are approaching to the final result! 😩
😅 I'm not sure why it would crash your game. I just tested and it seems OK on transfers for me. Maybe one of your plugins is allergic to my code.

The shouldSuppressMapFade function controls when the fade out gets suppressed. As you can see, in the code I provided, it is set to return true. That means it always says "yes, suppress the fade out".

To change that, you could replace this:
JavaScript:
  const shouldSuppressMapFade = function(scene) {
    return true;
  };
...with something like this:
JavaScript:
  const shouldSuppressMapFade = function(scene) {
    return $gameSwitches.value(47);
  };
I.e. "the fade out is suppressed iff game switch 47 is ON". 👋
😅 I'm not sure why it would crash your game. I just tested and it seems OK on transfers for me. Maybe one of your plugins is allergic to my code.

The shouldSuppressMapFade function controls when the fade out gets suppressed. As you can see, in the code I provided, it is set to return true. That means it always says "yes, suppress the fade out".

To change that, you could replace this:
JavaScript:
  const shouldSuppressMapFade = function(scene) {
    return true;
  };
...with something like this:
JavaScript:
  const shouldSuppressMapFade = function(scene) {
    return $gameSwitches.value(47);
  };
I.e. "the fade out is suppressed iff game switch 47 is ON". 👋
Yeah, now it works all like a charm! Thanks a lot to all here who helped me!
For curiosity: yea, the problem was the ABS plugin that I'm using, somehow it crash my game when teleporting without a fade-in option. Idk why, but now it's working...
So many thanks!

Original thread: https://forums.rpgmakerweb.com/threads/how-to-refresh-game.164131/