Jump to content
Sign in to follow this  
Rinku

Globally Reset Self Switches

Recommended Posts

Hello, is there a way to globally reset a self-switch for all events?

Scenario: I would have numerous versions of the typical chest event which is permanently deactivated by use of a Self-Switch (Let's say C). I would like a feature in my game to be able to turn off Self-Switch C for ALL events (across all maps) in one call. 

 

I have come across Kadokawa's OuterSelfSwitch, but it only affects events on the map it is being called.
I have also come across this piece of coding from Hime: 

 

class Game_SelfSwitches
def bulk_set(letter, state)
switches = @data.keys.select {|data| p data; data[2] == letter }
switches.each {|key| self[key] = state }
end
end

class Game_Interpreter
def bulk_self_switch(letter, state)
$game_self_switches.bulk_set(letter, state)
end
end

 

Script call: bulk_self_switch("A", false)

(Source: http://www.rpgmakercentral.com/topic/30665-resetting-self-switches-a-only/)

However, that is for VX Ace. Is there an MV equivalent to the above coding or another alternative to globally resetting a particular self switch? 

Share this post


Link to post
Share on other sites

Solution:

Game_SelfSwitches.prototype.bulk_set = function(letter, state){
for(var key in this._data) {
if(key[key.length-1] == letter) {
this._data[key] = state;
console.log('setting ' + key + ' to ' + state);
}
}
};


Game_Interpreter.prototype.bulk_self_switch = function (letter, state) {
$gameSelfSwitches.bulk_set(letter, state);
};

this.bulk_self_switch("A", false)
Edited by Rinku

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×