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!
Help with simplifying a script
● ARCHIVED · READ-ONLY
-
-
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? -
Code:
for (let i = 1; i < 25; i++) $gameSelfSwitches.setValue([171, i, 'A'], false);
Simple as that. -
Turning off the self switch for event ID starting at 1 and ending at 24?
It's the perfect situation for a "for loop". -
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? -
I already provided the answer.
-
I already provided the answer.
Yeah sorry. I was gathering screenshots and didn't realize so. Thanks! You saved my bacon!