Self Switch Script call for multiple events on a map

Random Panda

Veteran
Veteran
Joined
May 3, 2016
Messages
91
Reaction score
14
First Language
English
Primarily Uses
RMMV
Hi All,

I need to use
Code:
$gameSelfSwitches.setValue([$gameMap._mapId, EVENTID, 'A'], false);
But for EVENTID I was hoping to use an array of multiple event IDs so I don't have to redo that code for multiple events. Something like this, but you know, done correctly:
Code:
var E = [1,5,9, etc.]
$gameSelfSwitches.setValue([$gameMap._mapId, E, 'A'], false);
I feel like I found that a while ago but i can't for the life of me find it again. Could anybody here help show me how I could do that?
Any help is greatly appreciated.
 

Dopan

Veteran
Veteran
Joined
Mar 27, 2020
Messages
500
Reaction score
228
First Language
German
Primarily Uses
RMMV
Solution:
JavaScript:
                Game_Interpreter.prototype.allEvSelfSwitch = function(letters, false/true) {
                    for (var i = 1; i <= $gameMap.events().length; i++) {
                    var event = $gameMap.event([i]);
                    //use extra if conditions here if needed
                        var key = [this._mapId, ([i]), letters];
                        $gameSelfSwitches.setValue(key, false);
                    
                
                    }
                };
I edited one of My Plugins Scripts.. this should do what you want, it will set all SELf Switches of all Events on Map to the "true or false" ..where "letters" are 'A' ,'B', 'C' or 'D' ...

You can use extra If Conditions to include or exclude some GameMap Events

as example this is the original Script which i use in my plugin SRPG_UnitGroups.js:
Another Example:
JavaScript:
                //12T_reset SelfSwitch: "this.allTxSelfSwitch(checkId, letters, "team")"
                Game_Interpreter.prototype.allTxSelfSwitch = function(checkId, letters, team) {
                    for (var i = 1; i <= $gameMap.events().length; i++) {
                    var battleunit = $gameSystem.EventToUnit([i]);
                    var eventunit = $gameMap.event([i]);
                    if (battleunit && eventunit && (battleunit[0] === 'actor' || battleunit[0] === 'enemy') && (!battleunit[1].isDead())) {
                        if (battleunit[1].isStateAffected(checkId) && (battleunit[1].srpgTeam() == team)) {
                            var key = [this._mapId, ([i]), letters];$gameSelfSwitches.setValue(key, false);
                        }
                    }
                
                    }
                    return true;
                };
(I only use this to reset all SelfSwitches thats why my example Script dont ask for true of false in the function "()"..)
 
Last edited:

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,072
Reaction score
1,493
First Language
EN
Primarily Uses
RMMZ
setValue sets one switch at a time, so you need use a loop here. E.g.
JavaScript:
var m = $gameMap.mapId();
[1,5,9].forEach(function(e) {
  $gameSelfSwitches.setValue([m, e, 'A'], false);
});
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

grief... lol... I keep seeing request for MZ versions of MV plugins. this is why I haven't moved over and just MZ for my MV project.
Egg-sitting minigame is coming along nicely. Are you a bad enough dino to keep all these raptor eggs warm?

I forgot to post the animated version of the previous map I was working on. I'm still arguing with myself on if I like the stark blue ground better than the undergrowth ground used on the waterfall map. Hmm...
now that fmod is free for indie(<200k revenue), it would be interesting to see someone add fmod support for rpg maker
Can't say I can't promise progress on a project just yet. But I can say I had fun databasing tonight. :)

Forum statistics

Threads
105,802
Messages
1,016,579
Members
137,496
Latest member
sulthorne
Top