Automove tiles

For some reason I use my own script for movement. Unfortunatly, if user keep press a directional arrow he ill still be able to move out of the path.


Any idea why and how solve this?

ccccxx.png
That's not a script - it's an event.  Try not to get the terms mixed up, as they mean different things and can't be used interchangeably.


Can you explain the logic of what you're trying to do?  Without stating the rules and what should happen, it's hard to see which part might cause it to work incorrectly.  It looks like you're trying to do something based on terrain tags, but it's the terrain tag of the player's current location, not where they are about to move to.  Is that right?  What should happen in each case (for those of us who only speak English)?


It may be that the problem is it's NOT a script, but an event.  Processing a list of event commands is slower than script, and the engine has its own script controlling player movement.  It may be that your event commands are not getting executed fast enough, allowing the real script a chance to take over based on player input.
They have 5 different terrain tag. 3 for Ice kind, mean that when player move on it, he will move forward until bloqued by something.


4-5-6-7 are arrow based. Player will automaticly move in the direction of the arrow.  The reason I use my own code instead of script its


because some monster and objet will have the same reaction and script that I found work for player only.


Curently, it's look the terrain tag and react depending of terrain tag. But if player keep press right for exemple on a serie of left arrow, player


will move right and left and so on. I don't know how to solve that. I hope I more clear this time. I put all in an parallele event on the map.
Are you saying you WANT the player and NPC to have the same reaction and they don't, or that they do have the same reaction and you don't want them to?


If you're going to control movement with your event, you probably should have a flag that prevents the scripts from handling it.  You can do this by creating a switch called 'Manually Control Player' or something like that and modifying the Game_Player.moveByInput function to NOT move if this switch is on.  Then you turn the switch on when the player is on any of these tiles, and off when they're not.  If it's one big puzzle you can just turn it on when they start the puzzle (make their first move onto the ice) and off again when they get to the end.


You would need to go to the rpg_objects.js script and insert the following after line 7592 (which should be Game_Player.prototype.moveByInput in MV 1.2.0 - if it's not, just find that function and insert the following as the first line):


if ($gameSwitches.value(12)) { return };


replacing the 12 by whatever switch number you want to use.  Of course, because you're updating the js files directly instead of using a plugin, if MV is updated and you replace the files so you have the latest version, you'll have to do the change again.


See if that makes it work or causes other issues, and if it's no good we'll remove the line and go back to the event.  And in that case can you post screenshots to show the rest of the event?
The reason I doing the code myself is because some objet will react the same when when he see arrow.


I wil ltry what you say, but maybe I need to look for plugin because I want to avoid change directly in the js file.
Yeah - I think there's an issue with my idea, so maybe just forget changing the js file.  At some point you'll need them to be able to change direction.


There probably is a plugin to do this already.
Maybe I can desactivate all input untill movement done. I think my trouble come from the fact that I use paralelle movement for each time. So between to refresh of the parallele event, user can move. MAybe I need to do a loop that will do all movement until done.


I think that if you give the the script for check terrain tag I will be able to do it.
parallel events loop by default.  You'd have to show us the full event before we can say that's the cause or not.
I think I found a solution and I will post it soon, but first I need to find out how within a script stop player movement and make him move. thanks =:0)


Curently it's not working. player don't move and game crash. I think that it's not easy to make player move inside a script.

vfdfddddd.png
It would be helpful if you would give the full error message - preferably with a printout of the console log.


That all looks okay to me, except you left out the () for $gamePlayer.moveForward()


You also have a logic error.  Your block continues to run while t is 3, 4, 5 or 6.  But you set direction if t is 4, 5, 6 or 7.  The case 7 will never be executed, because if t is 7, it will never get through the while test.  There might also be an issue with everything happening in the loop - you're not giving it a chance to do any graphic or input updates.  I don't think you want all of this inside a single script call - you need to give it a chance to come up for air and let something else have a look-in, otherwise I expect it might freeze your game.
You are right about the 7 I forget it. And yes they have no error, the game jsut freeze. But I want to be able to do it inside the script, for learning also.


The () solve the issue =:0)


But it's don't wait for completion, if I put a long path he go directly at the end. What is the best way for wait for completion(of the player movement)? The while loop and condition fail because it's not wait for player  movement completion.


Look my curent code: (note the updateroutemove was removed, that was jsut a test)


dfdfdfdf.png
Did I need to put more information? Im not clear or nobody have any idea? I still try to find a way, but nothing work =:0(

Original thread: https://forums.rpgmakerweb.com/threads/automove-tiles.64180/