Help with simplifying a script

MintWhelp

Villager
Member
Joined
Oct 18, 2012
Messages
8
Reaction score
1
First Language
Spanish
Primarily Uses
So, I got a script that looks like this:

$gameSelfSwitches.setValue([171, 1, 'A'], false); $gameSelfSwitches.setValue([171, 11, 'A'], false);

$gameSelfSwitches.setValue([171, 2, 'A'], false); $gameSelfSwitches.setValue([171, 12, 'A'], false);

$gameSelfSwitches.setValue([171, 3, 'A'], false); $gameSelfSwitches.setValue([171, 13, 'A'], false);

$gameSelfSwitches.setValue([171, 4, 'A'], false); $gameSelfSwitches.setValue([171, 14, 'A'], false);

$gameSelfSwitches.setValue([171, 5, 'A'], false); $gameSelfSwitches.setValue([171, 15, 'A'], false);

$gameSelfSwitches.setValue([171, 6, 'A'], false); $gameSelfSwitches.setValue([171, 16, 'A'], false);

$gameSelfSwitches.setValue([171, 7, 'A'], false); $gameSelfSwitches.setValue([171, 17, 'A'], false);

$gameSelfSwitches.setValue([171, 8, 'A'], false); $gameSelfSwitches.setValue([171, 18, 'A'], false);

$gameSelfSwitches.setValue([171, 9, 'A'], false); $gameSelfSwitches.setValue([171, 19, 'A'], false);

$gameSelfSwitches.setValue([171, 10, 'A'], false); $gameSelfSwitches.setValue([171, 20, 'A'], false);

$gameSelfSwitches.setValue([171, 21, 'A'], false); $gameSelfSwitches.setValue([171, 22, 'A'], false);

$gameSelfSwitches.setValue([171, 23, 'A'], false); $gameSelfSwitches.setValue([171, 24, 'A'], false);

I use this script to make, say, rooms that are identical in layout look slightly different by adding NPCs/stuffs on it via events, as a way to save on amount of maps. Think of it as you entering a classroom, and, while the size and amount of chairs/tables are the same, the things on the tables, walls and kids you can talk to are different.

Anyways, is there a way to simplify this script, or make it more efficient?

Thanks in advance!
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Just for the sake of clarity, that is not a script, but a series of script calls.
Where are you executing those calls? Is it from, e.g. a Common Event, or is it a parallel process event (with, I assume, 'Erase Event' as the last command) on the particular map in question?
Why do you have them in pairs, numbered 10 apart? Is that simply coincidence in the example you have chosen, or is that consistant?
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,639
First Language
Czech
Primarily Uses
RMMV
Code:
for (let i = 1; i < 25; i++) $gameSelfSwitches.setValue([171, i, 'A'], false);
Simple as that.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
Turning off the self switch for event ID starting at 1 and ending at 24?
It's the perfect situation for a "for loop".
 

MintWhelp

Villager
Member
Joined
Oct 18, 2012
Messages
8
Reaction score
1
First Language
Spanish
Primarily Uses
Just for the sake of clarity, that is not a script, but a series of script calls.
Where are you executing those calls? Is it from, e.g. a Common Event, or is it a parallel process event (with, I assume, 'Erase Event' as the last command) on the particular map in question?
Why do you have them in pairs, numbered 10 apart? Is that simply coincidence in the example you have chosen, or is that consistant?
The scripts are called whenever you enter a door... I think images can explain this better:

From the images, you can see that each door has the script calls that change the events in the other room, using their self switches. When you go out of that room, the transporting event also turns off the self switches that were activated in that room.

Then when you enter a different room, you actually enter the same room you entered before, but the events have different selfswitches on, thus making it look slightly different.

So, now that I know that they are several script calls... is there a way to make them, well, fewer in amount?
 

Attachments

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,639
First Language
Czech
Primarily Uses
RMMV
I already provided the answer.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,860
Messages
1,017,038
Members
137,568
Latest member
invidious
Top