[SOLVED] $gameTemp.reserveCommonEvent(ID); problems...

Hello there again, 


Using the script call list, I saw that this would run a common event using a script:


$gameTemp.reserveCommonEvent(ID);


So I used it and it worked great, however...after using it in a script, I then can't call any common events using eventing in my game. Does anyone know what's wrong? 
Remove the script call and see if other calls to common events will work okay.  I don't think this line of code would have that effect, so I want to confirm that removing/disabling the line does in fact make subsequent calls work correctly.
Are you calling that with a script call, or is that inside a plugin?


If it's a script call inside an event, is the regular "call common event" on the same event or somewhere else?
Hang on...posting the info now...


//CREATE
var alias_prototype_startmapscene = Scene_Map.prototype.start;
Scene_Map.prototype.start = function() {
alias_prototype_startmapscene.call(this);
//Starting code goes here

//Run all common events that are run at the beginning of every map's start/initialization
$gameTemp.reserveCommonEvent(18); //Clear all pictures (clears picture slots 1-20)
$gameTemp.reserveCommonEvent(20); //Unequip all items
}


These two pieces of code need to be run on every map's start. The info I have so far on the problem: 


- If I just do $gameTemp.reserveCommonEvent(18); or $gameTemp.reserveCommonEvent(1);. It could be an empty common event slot that's run, or one that does stuff. The same thing happens in where no common event of any kind will then run that's evented inside of RPG Maker MV. 


I think this could have to do with the fact that I'm doing it at Scene_Map.prototype.start = function() { } ...I'm not sure. 


If I take the line of code out completely, the $gameTemp.reserveCommonEvent(ID); out....then everything works fine again.


EDIT: and one last thing. Trying to do  $gameTemp.clearCommonEvent(); after reserveCommonEvent() does not work either. Maybe there's a solution in where I can run a common event a different way? 
You can only have one "reserveCommonEvent" per frame, as the second one overrides the first one (the common event is only really run at the next frame). If you have OrangeEventManager or OrangeTimeSystem on your project, you can use the following line instead:


$gameTemp.reserveOrangeCommonEvent(ID);


That way you can reserve more than one common event per frame and it won't get in the way of the regular common events called from events.
You can only have one "reserveCommonEvent" per frame, as the second one overrides the first one (the common event is only really run at the next frame). If you have OrangeEventManager or OrangeTimeSystem on your project, you can use the following line instead:



$gameTemp.reserveOrangeCommonEvent(ID);


That way you can reserve more than one common event per frame and it won't get in the way of the regular common events called from events.





Gotcha. I just found a similar fix over here as well: 





And that fixed the problem for me. I'm still worried about this creating problems for me in the future, but I will run some tests tomorrow to make sure this all checks out.


Thanks as always Hudell and Shaz.


EDIT: I still don't understand, though, why it's not running any common events AFTER the first frame of the map (using Scene_Map.prototype.start = function { } ), because Scene_Map.start shouldn't be run every frame but rather the very first frame of the map only...not getting that whole bit.....unless every time a common event is run the scene_map restarts...? actually now that I think about it that's probably the case.).


Oh...I think I understand it now. A Common Event is like a new map is starting up every time? Does running a common event start a new sub-map or something?
Why don't you just have a single common event that does the whole lot, if both of them need to run on map start?  You could also have it conditioned by a switch and set to parallel process, turning the switch off as the last command, and then turn the switch on from within the script.


I'm also not sure if that's the correct function to do this - does that run as EACH map is loaded, or only when $gameMap is created?  Game_Map.setup is the function/method I've always used to add stuff that needs to happen each time a map loads.
Scene_Map.start will run at every map change, every time the player opens and closes the menu, and after every battle. It really shouldn't bug your regular common events. Can you send a screenshot of the even where you're using the "call common event" command?
hmm ... in that case I'd also question whether the event is meant to run every time the menu is exited.
hmm ... in that case I'd also question whether the event is meant to run every time the menu is exited.



Well, for every map I run a common event called "Clear All Pictures" which clears pictures 1-20, as I'm using pictures for parallax backgrounds. This needs to run every single time a map is started, so it worked out in the end. There are also 2 other common events I'm running based on the gameplay the game has. It's a click and point adventure puzzle game, so you equip items on a map, and then when you go to the next map it unequippes those items, so I needed to have another common event run called "Unequip All Items".


The third common event I have running is due to the fact that RPG Maker MV has a problem in where when the player object switches it's graphics to a different charset, it blinks if the graphic is not preloaded. So, I have a common event that checks a variable for what clothing the character is wearing (PlayerClothing = 2) for example, and then preloads all frames by simply doing a Set Movement Route and Change Graphic really fast. Since it all happens in a single frame, the changing of graphics is unnoticeable. 


I got what I wanted, though, so I have to thank you both again for all your help. 
You could also use preload manager to preload all graphics.
You could also use preload manager to preload all graphics.



I tried that and for whatever reason it isn't working. Only if I actually use change graphic through eventing does it stop the blinking from happening. I have TDDP_PreloadManager running. I also tried some code for manually preloading the graphic using javascript. Same thing happens, so for whatever reason change graphic is what's working. Don't know why, but I can cope with it.

Original thread: https://forums.rpgmakerweb.com/threads/solved-gametemp-reservecommonevent-id-problems.63430/