Clear ALL selfswitches

sertianscompany

Villager
Member
Joined
Nov 26, 2015
Messages
16
Reaction score
5
First Language
ESP EN
Hello! :)

I'm doing a puzzle game and to be able to restart the level, I need to clear all the self switches of the map, BUT not all the selfswitches of the game (cause I have a common area which has self switches).

I know that this script code: $gameSelfSwitches.clear() clears all the self switches, but I need something similar only for the map ID I want.

Is it possible to do that?

Thanks! :)
 

Prizm Daystar

Social Butt
Veteran
Joined
Nov 22, 2015
Messages
80
Reaction score
19
First Language
English
My first question is:  Where are you using that script code at in your game?

My second question is:  Wouldn't it be easier, on an event that exits the map, to simply reset the self-switches for that map after a Fadeout Screen and before a Transfer Player event?

So it would be like --  Fadeout Screen

                                  Control Self Switch A = OFF

                                  Control Self Switch B = OFF

                                  Control Self Switch C = OFF

                                  Control Self Switch D = OFF

                                  Transfer Player = Map, (x, y)

                                  Fadein Screen
 

Dinamic Creates

Project Stealth | Project Dungeon Trios
Veteran
Joined
Nov 27, 2014
Messages
69
Reaction score
24
First Language
Spanish
Primarily Uses
RMMV
So it would be like --  Fadeout Screen

                                  Control Self Switch A = OFF

                                  Control Self Switch B = OFF

                                  Control Self Switch C = OFF

                                  Control Self Switch D = OFF

                                  Transfer Player = Map, (x, y)

                                  Fadein Screen
That seems easier, specially if those commands start by a big Switch from another event.

You know, the event that exits the map would do this

Fadout Screen

Switch ON

Transfer Player = Map (X,Y)

Fadein Screen. 

The switch will trigger the last page ( paralel process) of all of your events  with self switches, and that page will do the 

                                  Control Self Switch A = OFF

                                  Control Self Switch B = OFF

                                  Control Self Switch C = OFF

                                  Control Self Switch D = OFF

                         Control Switch = OFF

 

I'm almost sure that none of the events will stay with the selfswitches with this, and also you could use the switch for future maps.
 
Last edited by a moderator:

Prizm Daystar

Social Butt
Veteran
Joined
Nov 22, 2015
Messages
80
Reaction score
19
First Language
English
That seems easier, specially if those commands start by a big Switch from another event.

You know, the event that exits the map would do this

Fadout Screen

Switch ON

Transfer Player = Map (X,Y)

Fadein Screen. 

The switch will trigger the last page ( paralel process) of all of your events  with self switches, and that page will do the 

                                  Control Self Switch A = OFF

                                  Control Self Switch B = OFF

                                  Control Self Switch C = OFF

                                  Control Self Switch D = OFF

                         Control Switch = OFF

 

I'm almost sure that none of the events will stay with the selfswitches with this, and also you could use the switch for future maps.
Uh, wouldn't that turn off the Self-Switches for the map moved into?  I guess I'm just a little afraid of the way that looks.  I ought to try it myself and see if it works that way.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,477
Reaction score
12,023
First Language
English
Primarily Uses
RMMV
Do you only want to do this for a single map? In that case, make a Script command like this:

keys = Object.keys($gameSelfSwitches)keys.forEach(function(ssid)) { map = ssid[0] if (map == X) { $gameSelfSwitches[ssid] = false }}Replace the X in the (map == X) line with the map id, no leading zeros. So if you wanted to do it on map 15, that line would read:
Code:
if (map == 15)
If you want to do it on several maps, you could put the above into a common event and change that line to this:

if (map == $gameVariables.value(X))where X this time is the id of a variable.Then you could use Control Variables to set it to whatever map you wanted to reset self switches on, and Call Common Event to execute the above.
 

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

Latest Threads

Latest Profile Posts

Julian Brooks wrote on Hudell's profile.
Hi, I'm trying to use the Orange Mapshot plugin on Mac, but it isn't working. Could you assist? I'm attempting to do Parallax Mapping. Thanks.
I can't believe my dlc flopped that hard. It's depressing. I'm a fricking failure at being a musician.
Person: "Taxes are bs and money is, too! Anarchy!!" *Literally anything goes wrong* Same Person: "Why hasn't the government fixed this???"
Stream will be live shortly with a session of Haunting Ground! Feel free to drop by!

Forum statistics

Threads
94,354
Messages
920,173
Members
124,111
Latest member
Azarae
Top