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
512
Reaction score
238
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,087
Reaction score
1,508
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

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,977
Members
137,563
Latest member
cexojow
Top