Nilom

Veteran
Veteran
Joined
Sep 9, 2013
Messages
178
Reaction score
40
First Language
German
Primarily Uses
RMMV
Hello!

How can I let the code in my plug in wait until Scene_Boot.start was executed, so that I can use $gameActors.(i) and so on?

Thank you in advance! :LZSsmile:
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
32,112
Reaction score
7,999
First Language
German
Primarily Uses
RMMV
That completely depends on what the plugin does - there are several different answers to this, depending on where in the engine your plugin hooks into it.

if the plugin is hooked into the various update functions then the question is into which ones and when they're called.
if the plugin provides functions for events there is no need for such a thing because it wouldn't activate earlier anyway.
and if everything else fails you can simply define your own switches and skip your own functions untile the switches are activated at whatever time you want.
 

Nilom

Veteran
Veteran
Joined
Sep 9, 2013
Messages
178
Reaction score
40
First Language
German
Primarily Uses
RMMV
First, thank you for your reply!

Let me explain what I'm trying to do:
I'm using Yanfly's Enhanced TP to have various classes have their own TP mode.

My issue with the plugin is, that I can not set a classes TP mode with notetags. Only an actors.
That's why I need a way to check the class ID on game start, to manually set the TP mode. And I need it to work for the editors test battles too.

I've set this code up, so far:
Code:
for (var i = 1; i < 5; i++) {
    let a = $gameActors.actor(i);
    switch(a._classId) {
        case 1: console.log("Actor "+i+" is Class ID "+a._classId+": "+a.currentClass().name);
            if (a.skills().contains($dataSkills[102]) && a._tpMode !== 1) { console.log("Specifically a Titan!"); a.setTpMode(1); console.log("TP Mode 1 set"); } else { console.log("TP Mode already set to 1"); }
            if (a.skills().contains($dataSkills[103]) && a._tpMode !== 2) { console.log("Specifically a Wrath!"); a.setTpMode(2); console.log("TP Mode 2 set"); } else { console.log("TP Mode already set to 2"); }
            if (a.skills().contains($dataSkills[104]) && a._tpMode !== 2) { console.log("Specifically a Weapons!"); a.setTpMode(2); console.log("TP Mode 2 set"); } else { console.log("TP Mode already set to 2"); }
        break;
        case 2: console.log("Actor "+i+" is Class ID "+a._classId+": "+a.currentClass().name);
            if (a._tpMode != 3) { a.setTpMode(3); console.log("TP Mode 3 set");} else { console.log("TP Mode already set to 3"); }
        break;
   }
}

First I tried to use this code on battle start. With Yanfly's Base Troop Events. But for some reason it doesn't update any TP modes, although the TP mode ID of the battler changes in the developer tools.

So I tried to let this script run on game start instead.
But I get this error:
Uncaught TypeError: Cannot read property 'actor' of null


What can I do? :LZSsmile:


Oh and I would also be very thankful if someone could tell me how I can use the TP mode notetags for the classes too. I think it should'nt be too hard to implement this, but I failed. :LZSgrin:
 
Last edited:

Nilom

Veteran
Veteran
Joined
Sep 9, 2013
Messages
178
Reaction score
40
First Language
German
Primarily Uses
RMMV
.push(this.Thread)
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
32,112
Reaction score
7,999
First Language
German
Primarily Uses
RMMV
make that code into a function and call that function on gamestart from an autorun event would probably be the easiest solution
 

Nilom

Veteran
Veteran
Joined
Sep 9, 2013
Messages
178
Reaction score
40
First Language
German
Primarily Uses
RMMV
Yes the easiest. The problem with this is that the TP system wouldn't function correctly in test battles and I use them quite a lot. And they are much faster to set up than manually changing the party, the equip, the level, the enemy and so on.

Meanwhile I already changed the code into a function. Do you know where I could paste my function call so that it will be called after the game is set up?
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,266
Reaction score
1,673
First Language
EN
Primarily Uses
RMMZ
If you're sure that's the correct place to call the code, just implement an alias, e.g.
Code:
(function(alias) {
  Scene_Boot.prototype.start = function() {
    alias.apply(this, arguments);
    yourFunctionGoesHere();
  };
})(Scene_Boot.prototype.start);
 

Nilom

Veteran
Veteran
Joined
Sep 9, 2013
Messages
178
Reaction score
40
First Language
German
Primarily Uses
RMMV
If you're sure that's the correct place to call the code, just implement an alias, e.g.
Code:
(function(alias) {
  Scene_Boot.prototype.start = function() {
    alias.apply(this, arguments);
    yourFunctionGoesHere();
  };
})(Scene_Boot.prototype.start);

Awesome, thank you! I will try this out asap. :LZSsmile:

Edit: It works perfectly fine now! The TP modes are well updated in test battles. :kaoluv:
 
Last edited:

Latest Threads

Latest Profile Posts

Today is the day! I will be productive in game dev work! I will - *gets distracted by cat playing with her toy mouse* Awww <3
Whelp. I tried to be productive.
Decided to work on Fandom Scouts today. I've decided that instead of using the generic "scrolling text" event that MV has (I'm using MV for FS, not MZ) I'll use the movie option. I'm still trying to find a way to get Premiere Pro to output the compatible format though. If anyone can give me some help, it would be greatly appreciated!
Barthdry wrote on tln143's profile.
Hello tln143 Welcome to the RPG Maker Forum. We wish you enjoy and make good rpg games
Barthdry wrote on 00cassiesmells's profile.
Hello 00casiemells Welcome to the RPG Maker Forum. We wish you enjoy and make good rpg games
Remember guys: Drink water and workout is important too! Don't stay too much time on the PC working! :D

Forum statistics

Threads
109,037
Messages
1,041,518
Members
141,523
Latest member
Zereitzu
Top