Heya all :kaohi: i need a way to force the current map to reload (what happens when you exit and re-enter the map) via scriptcall.
Why? Im spawning events and i need a way to clear these when the process involving them is done, which is done via transferring map right now.
Im aware of using a dummy map transfer and go back to the map the player was in but this involves cutting part of an event process which can lead to a softlock if the player uses items at the wrong time (im using a real time system and trying to patch the inventory atm) also fading out/in between the maps disrupts the pace more than i'd like, so if it can be done in map via code/script please let me know!
Reset map scriptcall?
● ARCHIVED · READ-ONLY
-
-
This part of it shouldn't be a concern, you can specify no fade in a Transfer Player command.Im aware of using a dummy map transfer and go back to the map the player was in but...fading out/in between the maps disrupts the pace more than i'd like
I'm not sure how to address your main question in the way you asked...I should think a script call that simply despawns all of the events would have fewer unintended consequences than reloading the map.
But I could be wrong for your purposes, and I don't know what method you're using to spawn the events in the first place. -
This is the code that I'm using, it helps you to erase spawned events and requests a full refresh of your map. However, some 3rd party plugins such as MV3D may not react to it.
Code:$gamePlayer.requestMapReload(); $gameMap.requestRefresh(); $gameMap.events().forEach(event => event.erase()); $gamePlayer.reserveTransfer($gameMap.mapId(), $gamePlayer.x, $gamePlayer.y, 0, 2); -
Are you using an event spawning plugin to spawn these events, I assume? Usually, there's a way to grab the ID of the last spawned event with script calls from these plugins. I think the one I use (Yanfly's) has a script call to grab the IDs of all spawned events, although I'm not sure if this is overall or per map. Anyway, if you have access to such a script call, could you use this to despawn them all at once when you need to? Or if you can only get the last spawned ID, could you set the value of a game variable to an empty array before these events start spawning, and then add the ID of each one to the array as they spawn - and then use this array to despawn them?
If you did the second option, given the nature of game variables, I imagine you'd have to do it something like this:
JavaScript:// Before spawning any of the events $gameVariables.setValue(variableId, []); // Each time an event is spawned let eventIds = $gameVariables.value(variableId); eventIds.push(scriptcallforlastID()); $gameVariables.setValue(variableId, eventIds); // To despawn them all let eventIds = $gameVariables.value(variableId); eventIds.forEach(id => scriptcallfordespawn(id));
That would also be ideal if you end up having any other spawned events that you DON'T want to reset, you can only add the spawned event IDs to the array that you will want to despawn together - and avoids a full map refresh if you have other things that might get messed up.
Disclaimer: I have not tested the code above (I'm in class), but let me know if it doesn't work or you don't understand it. And if you aren't using a plugin to spawn the events and can't get their IDs... welp ¯\_(ツ)_/¯