Setting Movement Route for a Variable Event ID

UPDATE:

I've got it mostly working, but am having issues with the movement route scripting.

I am currently trying:

$gameMap.event($gameVariables.value(34)).setImage(!Crop_Wheat, 3)
$gameMap.event($gameVariables.value(34)).setDirectionFix(false)
$gameMap.event($gameVariables.value(34)).setDirectionFix(true)
$gameMap.event($gameVariables.value(34)).setDirection(2)

(Used as scripts in a Set Movement Route function in another event on the same map)

This is not working at all. Have I written this wrong? It seems to be in line with the references I've seen. The variable 34 referenced is a variable that sets what event ID I am moving.
You can tackle this from an event using the Game Interpreter controlling everything on the map rather than the moveroute of an event. Whenever you have a script in a move route like this.jump_forward(1) you can do the same thing from its own or another event page with this.character(eventId).jump_forward(1) instead
You can tackle this from an event using the Game Interpreter controlling everything on the map rather than the moveroute of an event. Whenever you have a script in a move route like this.jump_forward(1) you can do the same thing from its own or another event page with this.character(eventId).jump_forward(1) instead

I am not too sure if this would work, as it is not being run from an event. Rather, it is a common event, which is run from another common event which is triggered by a switch (which is turned on by a plugin).

Can this be used to set move routes for other events, such as doing: this.character($gameVariables.value(34)).jump_forward(1), setting the movement for a specific event from a script in a common event?
I am not too sure if this would work, as it is not being run from an event. Rather, it is a common event, which is run from another common event which is triggered by a switch (which is turned on by a plugin).

Can this be used to set move routes for other events, such as doing: this.character($gameVariables.value(34)).jump_forward(1), setting the movement for a specific event from a script in a common event?
Yes, putting the script in the page of a common event uses the Game Interpreter, which you can control the player ans all events from. The syntax is the same.
Yes, putting the script in the page of a common event uses the Game Interpreter, which you can control the player ans all events from. The syntax is the same.

Awesome, that should work perfectly then.

Does this look about right?

if($gameMap.mapId() == 34); (the map I need to be on for this to matter, so it wont affect random events if run while I'm on other maps)
this.character($gameVariables.value(34)).setImage(!Crop_Wheat, 3);
this.character($gameVariables.value(34)).setDirectionFix(false);
this.character($gameVariables.value(34)).setDirection(2);
this.character($gameVariables.value(34)).setDirectionFix(true);
If this only happens on one map you should just use an event on that map instead of a common event that runs on every map to check if it's a certain map.
If this only happens on one map you should just use an event on that map instead of a common event that runs on every map to check if it's a certain map.

Ah, yeah that would be simpler.

Does that script look like it should work as-is if run from another event on the same map?

EDIT: Hmmm, not working.

I also tried:

$gameMap.event($gameVariables.value(34)).setImage(!Crop_Wheat, 3)
$gameMap.event($gameVariables.value(34)).setDirectionFix(false)
$gameMap.event($gameVariables.value(34)).setDirectionFix(true)
$gameMap.event($gameVariables.value(34)).setDirection(2)

This is in a "set Move Route" event function on the same map in a different event, but it is not doing anything.

Hmmm...
Where and how are you running the code? Could you show the event? Also, each line should have a semicolon at the end of the command. '!Crop_Wheat' may need to be in quotes since it's a string. Press F8 or F12 to bring up the console log.
Where and how are you running the code? Could you show the event? Also, each line should have a semicolon at the end of the command. '!Crop_Wheat' may need to be in quotes since it's a string. Press F8 or F12 to bring up the console log.

Sure thing, here is the common event with this Move Route code:

movweroute.JPG


And this is the event running it:

movweroute2.JPG


The text above the move route is there to test that it is running this section under the right conditions. it is just the Set Move Route itself that isn't doing anything.

I tried the quotations for the sprite sheet name as you suggested, but it didn't change anything.
What is $gameVariables.selfValue? I've never heard of it. Could you take out the block of code this thread was about and put it in an autorun function on the map with an erase event at the end instead of the confusing mess of code you wrapped it up in?
What is $gameVariables.selfValue? I've never heard of it. Could you take out the block of code this thread was about and put it in an autorun function on the map with an erase event at the end instead of the confusing mess of code you wrapped it up in?

$gameVariables.selfValue is from a plugin that sets self variables for events.

I actually got it working. Turns out there were a bunch of issues: I needed '!Crop_Wheat', not "!Crop_Wheat", which is what I was trying. I also set it to sprite sheet 3 when I needed 2, because I forgot it starts at 0 haha.

It is all working now! Thanks for all the help.

I did end up moving it to a separate autorun event. I originally hadn't because that caused it to run too late in my loop to target the right event as my target ID variable would have already incremented by then, but I just set it to affect the event ID - 1 and that worked it out. Not sure if removing it and accounting for being out of sync is more confusing, or keeping it in the mess of code, but oh well.

Original thread: https://forums.rpgmakerweb.com/threads/setting-movement-route-for-a-variable-event-id.164716/