[SOLVED]Run a common event at new game?

Discussion in 'RPG Maker MV' started by cedr777, Feb 11, 2019.

  1. cedr777

    cedr777 Veteran Veteran

    Messages:
    102
    Likes Received:
    25
    First Language:
    English
    Primarily Uses:
    RMMV
    Please help, I need a way to run a common event called "Initialize Variables" at game start. What this common event does is simply sets the corresponding values for variables that I want at game start.

    It needs to be run when the player has entered the map AND has to be compatible with Yami_SkipTitle.js because I am going to be using this for bugtesting purposes and thus will always load the game at different maps from start.

    Edit1:
    I am considering a way to do it by having a switch turned ON at game start so that it will act as trigger for the common event if set as Parallel process then turn it of once it has ran. But since all switches are turned OFF by default at game start, I can't do that.

    Edit2:
    OrangeOverlay plugin seems to set switches 1-4 on at the start, so I probably need a plugin that do domething similar like that as well for it to work.

    Please don't recommend Yanfly's Button common events as I'm using that already but am lazy always pushing buttons at game start. ;_;

    Edit3:
    If you guys think this post doesn't belong here and need to be moved to JS plugins requests, please do so. Because I'm not sure but there may already be a plugin that exists to do what I want.
     
    Last edited: Feb 11, 2019
    #1
  2. Shaz

    Shaz Veteran Veteran

    Messages:
    36,634
    Likes Received:
    10,640
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    You don't need a common event. Just put it in a map event, set to Parallel Process, and turn on a self switch at the end. Give the event a second page conditioned by that self switch, to ensure it only runs once.

    edit - if you're going to change your starting point, then maybe yes, put it in a common event, and make the map event do a Call Common Event command. There's really no way to make a common event run unless you call it from a map event, or turn on a switch if it's a parallel process event ... apart from making a little plugin that turns the switch on when a new game is started. That's just one of the joys of testing, if you want to jump around all over the place.

    You could have a "testing" map that has the event to set all your variables, and at the end transfer you to the real map you want to start on. But you're still going to have to change it each time you want a new map.
     
    #2
    cedr777 likes this.
  3. cedr777

    cedr777 Veteran Veteran

    Messages:
    102
    Likes Received:
    25
    First Language:
    English
    Primarily Uses:
    RMMV
    Yes, you're exactly right. Since I'm gonna be jumping from one map to another. But if possible I don't want to create a map event for each map I'll be testing.
    Can you recommend a plugin that turns a switch on at game start? Like the one that OrangeOverlay does at start?
     
    Last edited: Feb 11, 2019
    #3
  4. Shaz

    Shaz Veteran Veteran

    Messages:
    36,634
    Likes Received:
    10,640
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    I don't know of any. You will have to write one for yourself.

    Code:
    var temp_DataManager_createGameObjects = DataManager.createGameObjects;
    DataManager.createGameObjects = function() {
      temp_DataManager_createGameObjects.call(this);
      $gameSwitches.setValue(x, true);
    }
    where x is the id of the switch you want to turn on (without any leading zeros).

    Save that as a .js file in your plugins folder, add via the plugin manager, and turn it on.

    Make sure you turn the switch back off again right at the end of the common event.
     
    #4
    cedr777 likes this.
  5. cedr777

    cedr777 Veteran Veteran

    Messages:
    102
    Likes Received:
    25
    First Language:
    English
    Primarily Uses:
    RMMV
    WORKS! And best of all, fully compatible with Yami_SkipTitle.js. Tried it when starting from different maps.
    Thank you very much Shaz!, reporting this thread as SOLVED.
     
    #5
  6. Bex

    Bex Veteran Veteran

    Messages:
    905
    Likes Received:
    168
    First Language:
    German
    Primarily Uses:
    RMMV
    While Testplaying Press F9 than a menu opens where you can manipulate all switches and variables.
    Simply turn switch1 to On and continue game, now your common event runs.
    Should work easy and flawless in Testmode.
     
    #6
  7. cedr777

    cedr777 Veteran Veteran

    Messages:
    102
    Likes Received:
    25
    First Language:
    English
    Primarily Uses:
    RMMV
    Umm...well technically you're right, but that's not exactly the solution I was after.
    See, I want to run a common event called "Initialize Variables" at game start. And by that I mean immediately as soon as the map appears.
    Without having to press anything on the keyboard at all (similar to what Yanfly's ButtonCommonEvents does, or the F9 Developer mode I think.) or having to apply an event that does turn on a switch for it in each map that I want to test, which is almost a hundred now.

    It's to make bugtesting less tiresome.
     
    #7
  8. Bex

    Bex Veteran Veteran

    Messages:
    905
    Likes Received:
    168
    First Language:
    German
    Primarily Uses:
    RMMV
    Edit: I missread you, answer deleted. Sorry my english lacks sometimes.
     
    Last edited: Feb 11, 2019
    #8
  9. cedr777

    cedr777 Veteran Veteran

    Messages:
    102
    Likes Received:
    25
    First Language:
    English
    Primarily Uses:
    RMMV
    Yes, of course that will work too, but if you think about it, I would need to copy paste that Parallel event that I made on the first map to the other 100 maps each time I want to change my start point and run that common event. So I'll pass on that method thank you. ;_;
     
    #9
  10. Eliaquim

    Eliaquim Veteran Veteran

    Messages:
    293
    Likes Received:
    54
    Location:
    Brazil - Rio de Janeiro
    First Language:
    Portuguese - Br
    Primarily Uses:
    RMMV
    If you only want that common event to initialize some variables, you can try LinkedVariables.js from Shaz.
     
    #10

Share This Page