Wait for move route

Hello!

Is there a way to make the game wait for the end of a forced move route, or an option to execute the events prior to map loading?

I use a pathfinder that draws tiles (eg. road) every step it makes, but it is running inside of a move route.

The problem is that I need to draw a road inside  a river using a pathfinder that runs as a script call from a move route, and the move route is still running (it's called using "force_move_route") when the water is being drawn, which blocks the pathinder's way.

Even drawing the water after the move route call is blocking the path (I see its a parallel process).

The only way it works is if i change the water tile to not block the path, but I dont want the player to walk over the water (no jokes here hehe).

Looks like even using "force_move_route" the event is triggered only after finishing the map load.

Sorry if its confusing I did my best hahaha.

EDIT:

The event call is as follow:

event = Event.new(from.x, from.y) # this is a wrapper to simplify "RPG::Event"event.set_speed(6)event.set_frequency(5)evt = event.place($game_map.map_id) # this returns the instance of Game_Eventmr = RPG::MoveRoute.newmr.repeat = falsemr.skippable = falsemr.wait = truem = RPG::MoveCommand.newm.code = 45 # sript# "to.x" and "to.y" are parameters, means the desired end positionm.parameters = ['find_path(' + to.x.to_s + ', ' + to.y.to_s + ', true)'] mr.list.insert(0, m.clone)evt.force_move_route(mr)EDIT 2:

Im using JPS Pathfinding: http://www.rpgmakervxace.net/topic/23346-jps-pathfinding/

And what I'm trying to do is draw a random road on the map from the point [x1, y1] to [x2, y2], and I use the pathfinder because the map has some houses in it and I want the option to have a river that crosses the map, in this case the road needs to cross the river, like a bridge, but the river tile is blockable.

I'm using the move route because its the only way to trigger the event that I know of, if there's another way, its acceptable.

Forgot to mention, i tryed the script call from the event itself, but in this case the road is not drawn correctly, i guess the map must be loaded so the pathfinder can check the passable tiles

EDIT 3: I realized that JPS Pathfinding has an option to wait while the path is being traced and now I can block the player movement, which is good enough to hide this from the player, assumming that i can load a sprite or something meanwhile. Anyway the water problem still persists.

EDIT 4: For anyone interested, I gave up on blocking the water and used a script to change the player graphic when its over water, so it looks like swimming
Check the box "wait for completion" in the move route
Check the box "wait for completion" in the move route
I'm doing it on script, i created a wrapper for events, and then i call the move route as follow:

event = Event.new(from.x, from.y) # this is a wrapper to simplify "RPG::Event"event.set_speed(6)event.set_frequency(5)evt = event.place($game_map.map_id) # this returns the instance of Game_Eventmr = RPG::MoveRoute.newmr.repeat = falsemr.skippable = falsemr.wait = truem = RPG::MoveCommand.newm.code = 45 # sript# "to.x" and "to.y" are parameters, means the desired end positionm.parameters = ['find_path(' + to.x.to_s + ', ' + to.y.to_s + ', true)'] mr.list.insert(0, m.clone)evt.force_move_route(mr) As you can see I'm setting "wait" value as "true"

Gona edit OP for the code above.
To execute events prior to map loading, put the commands into a Parallel Process event that erases itself after they've run.


These need to be QUICK to run - a move route would not do it, as it'd still be in progress when the map fades in.


Edit: in that case, set the event's trigger to Parallel Process, and don't forget the Erase Event command at the end. I don't think this will do what you want though, as anything in a move route will not complete before the map is visible.
To execute events prior to map loading, put the commands into a Parallel Process event that erases itself after they've run.

These need to be QUICK to run - a move route would not do it, as it'd still be in progress when the map fades in.

Edit: in that case, set the event's trigger to Parallel Process, and don't forget the Erase Event command at the end. I don't think this will do what you want though, as anything in a move route will not complete before the map is visible.
Just tried it, the parallel process makes it slightly faster but didn't solve the problem,

I tried erasing the event after the "find_path" method and nothing changed :/
Maybe you should explain exactly WHAT you're trying to achieve, rather than how, and we can help you a bit better. Why are you using find_path (and which script are you using)? Why are you using a move route? What is it you want to set up before the player sees it?
Maybe you should explain exactly WHAT you're trying to achieve, rather than how, and we can help you a bit better. Why are you using find_path (and which script are you using)? Why are you using a move route? What is it you want to set up before the player sees it?
Im using JPS Pathfinding: http://www.rpgmakervxace.net/topic/23346-jps-pathfinding/

And what I'm trying to do is draw a random road on the map from the point [x1, y1] to [x2, y2], and I use the pathfinder because the map has some houses in it and I want the option to have a river that crosses the map, in this case the road needs to cross the river, like a bridge, but the river tile is blockable.

EDIT: I'm using the move route because its the only way to trigger the event that I know of, if there's another way, its acceptable.

EDIT 2: Forgot to mention, i tryed the script call from the event itself, but in this case the road is not drawn correctly, i guess the map must be loaded so the pathfinder can check the passable tiles
Yeah - let's see what you're doing in the event. If you want it to happen before the player sees the map, Move Route is not the way to go. I think a script call would be better, but need to see what you've currently got first.


How are you changing the terrain?
Yeah - let's see what you're doing in the event. If you want it to happen before the player sees the map, Move Route is not the way to go. I think a script call would be better, but need to see what you've currently got first.

How are you changing the terrain?

This is how i draw the water:

I run the entire map and theres a lot of condition to decide if the water will be drawn or not, so lets assume the postition [pos_x, pos_y] is a desired location:

for z in 0..2 $game_map.data[pos_x, pos_y, z] = @tiles.water[z] if $game_map.data[pos_x, pos_y, z] == @tiles.ground[z]endIn this case "@tiles" is an object holding an array for every tile I want to use, so "@tiles.water" is the array for the water, and "@tiles.ground" is an array for the ground.

And this is the code for drawin the path:

# this is the method called in the pathfinder bellow, its inside the "My_Map" module, the module is too bigdef self.print_path(x, y) for z in 0..2 $game_map.data[x, y, z] = @tiles.path[z] endend# this is the override for the pathfinder, which is called inside the move routeclass Game_Character alias 😛re_find_path :find_path def find_path(x, y, draw_path=false, dist = 0, lookahead_dist = 1, recalc_if_blocked = true) proc = Proc.new {|path, old_x, old_y| My_Map.print_path(old_x, old_y) if draw_path } # the "Proc_Controller" is a module that only holds the default "Proc" # there was a bug on the pathfinder trying to save a "Proc" object inside Game_Character Proc_Controller.set_proc_step(proc.clone) pre_find_path(x, y, dist, lookahead_dist, recalc_if_blocked) endendEDIT: I changed the code order and running parallel process did the trick for the water, BUT the player can still move while the path is being created.

EDIT 2: Nevermind edit above, now it's destroying the houses too

EDIT 3: I realized that JPS Pathfinding has an option to wait while the path is being traced and now I can block the player movement, which is good enough to hide this from the player, assumming that i can load a sprite or something meanwhile. Anyway the water problem still persists.
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.


at OP request.

Original thread: https://forums.rpgmakerweb.com/threads/wait-for-move-route.42555/