Movement route script problem-pls help!

DadGuyDrawing

Veteran
Veteran
Joined
Apr 15, 2020
Messages
55
Reaction score
17
First Language
English
Primarily Uses
RMMV
Hi,

I have an RPG Maker MV game with an event "Maid" character who at a certain time walks toward the exit and fades out (leaves). For some reason, the event moves to the exit properly, but the switch won't activate. I have the exact same code on another event and it works properly. Any help would be greatly appreciated!

At the designated time I activate the switch which turns on the event page for her to leave. In that event page's movement route I have the following code:

Event Pager 14 - Movement Route
Script: //travel to Exit
Script: if ($gameMap.event(this._eventId).regionId() === 8 || $gameMap.event(this._eventId).regionId() === 24 || $gameMap.event(this._eventId).regionId() === 9 ) { this.moveStraight(this.findDirectionTo(14, 20)) };
Script: if ($gameMap.event(this._eventId).regionId() === 13 ) { this.moveStraight(this.findDirectionTo(20, 16)) };
Script: if ($gameMap.event(this._eventId).regionId() === 14 ) { this.moveStraight(this.findDirectionTo(20, 22)) };
Script: //if at exit, fade
Script: if (this.pos(20, 22)) {$gameSwitches.setValue(1043, true)};

Event Page 15 - Movement Route
Switch 1043 required for page to run
Opacity: 200
Wait: 15 frames
Opacity: 150
Wait: 15 frames
Opacity: 100
Wait: 15 frames
Opacity: 50
Wait: 15 frames
Through On
Transparent On

Both movement routes are: "repeat movements" = true, "skip if cannot move" = false. Both pages are parrallel trigger.
 

Hyouryuu-Na

Sapphire Sodium
Veteran
Joined
Jun 15, 2017
Messages
930
Reaction score
2,181
First Language
Not English
Primarily Uses
RMMV
could you try replacing your last if condition with this:
JavaScript:
if ($gameMap.event(this._eventId).x==20 && $gameMap.event(this._eventId).y==22){
$gameSwitches.setValue(1043, true);
};
 

DadGuyDrawing

Veteran
Veteran
Joined
Apr 15, 2020
Messages
55
Reaction score
17
First Language
English
Primarily Uses
RMMV
I replaced it with your suggestion, but still same issue. :(
 

Hyouryuu-Na

Sapphire Sodium
Veteran
Joined
Jun 15, 2017
Messages
930
Reaction score
2,181
First Language
Not English
Primarily Uses
RMMV
Are you sure that the switch doesn't turn on? Did you check the debug menu? Or maybe the coordinates are wrong. Also, could you post a screenshot of the event in the editor if possible?
 

Hyouryuu-Na

Sapphire Sodium
Veteran
Joined
Jun 15, 2017
Messages
930
Reaction score
2,181
First Language
Not English
Primarily Uses
RMMV
I think I see the problem now. It might be because you're using the script from the autonomous movement route. Try pasting the script call to the event contents. And just a note, parallel event doesn't affect the autonomous movement route. It affects whatever's inside the event, inside the box in the right side.
 

DadGuyDrawing

Veteran
Veteran
Joined
Apr 15, 2020
Messages
55
Reaction score
17
First Language
English
Primarily Uses
RMMV
Still same issue :/

Its weird, because I used basically the same code and process as eariler on two earlier pages (13 and 14) and it works fine, but these two don't.
 

Hyouryuu-Na

Sapphire Sodium
Veteran
Joined
Jun 15, 2017
Messages
930
Reaction score
2,181
First Language
Not English
Primarily Uses
RMMV
I'm out of suggestions XD Hopefully someone else will drop by to give you some pointers.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,244
Reaction score
7,623
First Language
German
Primarily Uses
RMMV
there are two possibilities here: either the switch is turned but nothing reacts to it, or the switch is not turned because the condition (position) was wrong.

you need to find out which one of those is the case, then we can help - and in both cases it would help to see screenshots of the event instead of descriptions. I can't count the number of cases where the error was in the screenshots and those were different from what was described etc.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,050
Reaction score
1,479
First Language
EN
Primarily Uses
RMMZ
If you turn that switch on (e.g. via debug or a Control Switches command) does it stay switched on? I wonder if there's some event using that switch for something else.

The scripting looks OK to me, though I think it could be written more concisely, e.g.
JavaScript:
var r = this.regionId();
if ([8,9,24].indexOf(r) >= 0) this.moveStraight(this.findDirectionTo(14, 20));
else if (13 === r) this.moveStraight(20, 16);
else if (14 === r) this.moveStraight(20, 22);
else if (this.pos(20, 22)) $gameSwitches.setValue(1043, true);
Just erase the line-breaks and you can use it on a single line in a move route script element. Since move routes update by 1 command every frame the character is not moving, this should also eliminate any brief pauses between moves.
 

DadGuyDrawing

Veteran
Veteran
Joined
Apr 15, 2020
Messages
55
Reaction score
17
First Language
English
Primarily Uses
RMMV
This really helps Caethryl, thank you! I'll try it today after work.

If you turn that switch on (e.g. via debug or a Control Switches command) does it stay switched on? I wonder if there's some event using that switch for something else.

The scripting looks OK to me, though I think it could be written more concisely, e.g.
JavaScript:
var r = this.regionId();
if ([8,9,24].indexOf(r) >= 0) this.moveStraight(this.findDirectionTo(14, 20));
else if (13 === r) this.moveStraight(20, 16);
else if (14 === r) this.moveStraight(20, 22);
else if (this.pos(20, 22)) $gameSwitches.setValue(1043, true);
Just erase the line-breaks and you can use it on a single line in a move route script element. Since move routes update by 1 command every frame the character is not moving, this should also eliminate any brief pauses between moves.
ps
 

DadGuyDrawing

Veteran
Veteran
Joined
Apr 15, 2020
Messages
55
Reaction score
17
First Language
English
Primarily Uses
RMMV
I had really high hopes for this...Unfortunately, it didn't work for me. I made a new event to test it, and put a script call in the movement route like this (all in one line):

var r = this.regionId(); if ([8,9,24].indexOf(r) >= 0) this.moveStraight(this.findDirectionTo(14, 20)); else if (13 === r) this.moveStraight(20, 16); else if (14 === r) this.moveStraight(20, 22); else if (this.pos(20, 22)) $gameSwitches.setValue(1043, true);

but the event won't even show up.

In the Debugger console I get no errors...

On a side note, I also tried creating a function in visual studio using the same code called funMoveToExit() to see if I could just call several lines of code from a custom plugin, but of course that didn't work either. I guess if you call a function from javascript "this" object isn't the same as if you are scripting into the event itself.

I realize everyone is just offering help out of kindness, so really appreciate you all taking the time out to help me!
Screenshot 2020-10-21 220452.png
image_2020-10-21_220727.png
If you turn that switch on (e.g. via debug or a Control Switches command) does it stay switched on? I wonder if there's some event using that switch for something else.

The scripting looks OK to me, though I think it could be written more concisely, e.g.
JavaScript:
var r = this.regionId();
if ([8,9,24].indexOf(r) >= 0) this.moveStraight(this.findDirectionTo(14, 20));
else if (13 === r) this.moveStraight(20, 16);
else if (14 === r) this.moveStraight(20, 22);
else if (this.pos(20, 22)) $gameSwitches.setValue(1043, true);
Just erase the line-breaks and you can use it on a single line in a move route script element. Since move routes update by 1 command every frame the character is not moving, this should also eliminate any brief pauses between moves.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,050
Reaction score
1,479
First Language
EN
Primarily Uses
RMMZ
I had really high hopes for this...Unfortunately, it didn't work for me. I made a new event to test it, and put a script call in the movement route like this (all in one line):

var r = this.regionId(); if ([8,9,24].indexOf(r) >= 0) this.moveStraight(this.findDirectionTo(14, 20)); else if (13 === r) this.moveStraight(20, 16); else if (14 === r) this.moveStraight(20, 22); else if (this.pos(20, 22)) $gameSwitches.setValue(1043, true);

but the event won't even show up.
As I said, your move script looked OK in terms of reaching the destination and turning on the switch; my version should simply eliminate any 1~5 frame pauses between moves. :kaoslp:

If the event doesn't show up, I imagine you're testing from a save, rather than from new game. If so: test from a new game! Temporarily change the player starting position if necessary. Save data includes (amongst other things) all events on the map at the time of saving, along with their current move routes etc. This can include events you have removed or replaced since making the save file. :kaoback:

If testing from a new game doesn't immediately fix the problem...did you try this, and if so what was the result?
If you turn that switch on (e.g. via debug or a Control Switches command) does it stay switched on? I wonder if there's some event using that switch for something else.
 

DadGuyDrawing

Veteran
Veteran
Joined
Apr 15, 2020
Messages
55
Reaction score
17
First Language
English
Primarily Uses
RMMV
Sorry for the delay! So here's what I found:
Number 1: when I turn the switch (1043) on manually with the debugger it turns off so I think that you are right, there must be some other event turning it off, I will dig through and find that.

Number 2: I made a new, clean event with the no eventing/scripting in it except a custom movement route (the one line version that you posted) and started a new game. The event immediately disappears when the game launches.
I wonder if one of my plugins is messing this up...Screenshot 2020-10-24 110417.pngScreenshot 2020-10-24 110451.png
 

DadGuyDrawing

Veteran
Veteran
Joined
Apr 15, 2020
Messages
55
Reaction score
17
First Language
English
Primarily Uses
RMMV
Found the switch turning off problem (Number 1 above), thanks for that!

Also found out why the event was disappearing but still having the problem of the script in the movement route immediately makes my event disappear. The script I was using had this: "this.moveStraight(20, 22)" when it should have been "this.moveStraight(this.findDirectionTo(20, 22))"

However, still having problem with this part "else if (this.pos(20, 22)) $gameSwitches.setValue(1043, true);" However, when I turn the switch on manually it stays on.

Here's my new code that works, except for the switch turning on.

"var r = this.regionId(); if ([8,9,24].indexOf(r) >= 0) this.moveStraight(this.findDirectionTo(14, 20)); else if (13 === r) this.moveStraight(this.findDirectionTo(20, 16)); else if (14 === r) this.moveStraight(this.findDirectionTo(20, 22)); else if (this.pos(20, 22)) { $gameSwitches.setValue(1043, true) };"

To reiterate, turning the switch on manually works now, and the event moves to the location properly now, but the event doesn't seem to recognize that the event is in the correct location (20,22) nor turn on the switch (1043) when it gets there.
 

DadGuyDrawing

Veteran
Veteran
Joined
Apr 15, 2020
Messages
55
Reaction score
17
First Language
English
Primarily Uses
RMMV
Figured it out, had to move the "if (this.pos(20, 22))" statement to before the "this.findDirectionTo(20, 22)" statement.

Thank you so much for your help @caethyril , @Andar and @Hyouryuu-Na !

Doesn't Work:
"var r = this.regionId(); if ([8,9,24].indexOf(r) >= 0) this.moveStraight(this.findDirectionTo(14, 20)); else if (13 === r) this.moveStraight(this.findDirectionTo(20, 16)); else if (14 === r) this.moveStraight(this.findDirectionTo(20, 22)); else if (this.pos(20, 22)) { $gameSwitches.setValue(1043, true) };"

Works:
var r = this.regionId(); if ([8,9,24].indexOf(r) >= 0) this.moveStraight(this.findDirectionTo(14, 20)); else if (this.pos(20, 22)) $gameSwitches.setValue(1043, true); else if (13 === r) this.moveStraight(this.findDirectionTo(20, 16)); else if (14 === r) this.moveStraight(this.findDirectionTo(20, 22)); else if (this.pos(20, 22)) $gameSwitches.setValue(1043, true);
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Oh no. That moment when you try to fix something you modified in your game, like, a year ago but didn't want to fix then, and you now have no idea what you even did. Me right now, trying to figure out why my gold window is over stretched?
LittlePIGGY wrote on atreyoray's profile.
Where are you TT^TT
We need ARP_InGameManual for MZ
Oh my gosh. Thank you, Macy's! Thank you so much! You have made me very happy!
Happy Thanksgiving everyone! What are you thankful for? I'm thankful that I no longer have PTSD, and that I get to enjoy a good meal with my mom and stepdad! It might not be the same as before COVID, but at least I still get to enjoy the holiday!

Forum statistics

Threads
105,549
Messages
1,014,556
Members
137,225
Latest member
Eryndor
Top